Skip ActiveJob reloading callback in test env
What does this MR do?
Problem
- ActiveJob sets up a
:around
execute callback which ultimately triggersFileUpdateChecker#updated?
. - The
FileUpdateChecker#updated?
can be slow (0.1 to 0.4 seconds), especially with a large glob - For each mail scheduled for delivery (
#deliver_later
), we trigger this:around
execute callback. - It is arguable wether we need code reloading while running specs
Solution
Skip ActiveJob reloading callback in test env
Because we run ActiveJob inline in test env, there is probably no need
to have code reloading for this while specs are running. This removes
frequent calls to FileUpdateChecker#updated?
which is slow on macOS.
This speeds up specs which schedule mailers (mailer #deliver_later
uses ActiveJob) by a lot.
Before (master):
$ bundle exec spring rspec spec/services/notification_service_spec.rb
Running via Spring preloader in process 57985
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
..................................................................................................................................................................................................................................................................................................................................
Finished in 12 minutes 9 seconds (files took 2.81 seconds to load)
322 examples, 0 failures
After:
$ bin/rspec spec/services/notification_service_spec.rb
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
..................................................................................................................................................................................................................................................................................................................................
Finished in 6 minutes 13 seconds (files took 45.77 seconds to load)
322 examples, 0 failures
See also: #241148 detailed analysis, and https://gitlab.com/-/snippets/2010138
Screenshots
This screenshot shows how much time a FileUpdateChecker#updated
call can take (1s). Given we call it every time a schedule a mailer (`#deliver_later), this adds up.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
Edited by Thong Kuah