Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up to #47499 and #47510
This PR consists of 2 changes (commits):
Optimizing one of activerecord tests
I used https://github.com/y-yagi/minitest-test_profile to find the slowest tests. The slowest one (
Finished in 227.415914s, 40.3534 runs/s, 136.6659 assertions/s.
) took 10 seconds to run.To reproduce:
Before
After
Disabling debug.log on CI
This change was introduced before (in #47499) but was reverted after (in #47537). It was mysterious why
sqlite3_mem
tests were started to fail, so we decided to just revert. Back then, I was able to reproduce that failure locally (unfortunately without a stable--seed
, just running the tests enough times). When reverted, I ran tests 100 times and haven't seen a failure again. Now, I reintroduced that change and ran tests again for 100 times, and no failure! I saw recently some changes were merged onmain
that fixed some flaky behavior in tests (or something like that), so maybe that is relevant.I also ran
stackprof
testing both changes.Before (look at <======= marks)
After
Total execution time
Before:
Finished in 263.680025s, 34.8035 runs/s, 117.8701 assertions/s.
After:
Finished in 227.415914s, 40.3534 runs/s, 136.6659 assertions/s.
(35 seconds less)Additional
It is very easy to get the slowest tests in
rspec
by using a cli flag and it is possible forminitest
, but using an external gem that I used. Also, there was recently a UX addition to the rails test runner to be able to filter test cases by lines (line ranges). Wdyt on adding a native ability to rails test runner to print the slowest tests?