-
-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Mark some tests as slow and schedule them at the beginning #15950
base: master
Are you sure you want to change the base?
Conversation
(For what it's worth, I highly recommend using nextest rather than test for local development!) |
Right! Did not think about using nextest. 😄 Certainly has a better interface, but unfortunately tests are executing a bit longer :( I added nextest benchmarks to the table in the description. At first glance, performance improvements are similar to |
You could try the profile dedicated to CI - it's a bit more optimized: |
Although, I do like the idea of somehow trying to sort the test cases in decreasing real time duration. But I wish it was somehow ✨automagical✨, with no need to manually annotate anything. That sort (pun may or may not be intended) of thing is bound to get outdated. |
This PR is just a suggestion, I tried speeding tests up somehow and noticed that at the end my CPU was sitting idle. Regarding the I also thought about automating test annotation somehow. The idea of no annotations seems eerily close to the halting problem though ;) I was thinking about how to annotate the tests in order to schedule them properly. It could be the slow flag which divides tests into two categories, but it also could be a nondiscrete value (e.g. estimated execution time) which constitutes a total order. The latter seems to be an overkill, because (1) these values would be more dependent on the system, and (2) time improvement would be minimal compared to the former, which is a much simpler approach. Regarding automation, I thought about giving a feedback to the user about slow tests which are fast and non-slow tests which are slow. That would require two time values in order to create hysteresis. They could be set manually (e.g. 1s,10s), or calculated at the end based on the probability distribution (e.g. σ,2σ). That of course is a bit complicated so I did not go in this direction as I wasn't sure whether we would want this approach at all. That also sounds like a problem that possibly could be solved at a toolchain/library level. |
Of course, and thanks! :)
Bah, it could also be just a little system-local cache of "the last 5-10 times this test case was ran, it took xx milliseconds". Then to schedule, look up these records, average per case, and sort. The averaging should even out any discrepancies caused by P-core vs. E-core, powersave/performance, dynamic clocks, overall system load, thermal throttling, etc... And how a given test case is identified isn't that crucial either, as long as it works "reasonably enough", since it only determines the order of test executions, which shouldn't affect anything ™️, other than load balancing at the end, of course. This could even be a generic |
Ahh, see: nextest-rs/nextest#905 |
Okay, I think I found out why nextest does not run tests marked as slow; I also found out why tests on nextest are slower compared to Turns out The strategy of executing tests by nextest also explains why it's significantly slower than Removing the full walk on exact match makes nextest about 15s faster than before, which is closer to being as fast as |
1a196a2
to
12713e7
Compare
While I'm still not entirely sold on the manual |
Created a new PR with these two commits: #16031 |
I know I'm a bit late to the thread but
I'm not sure why I'd ever want that tbh. And I haven't really seen other projects do this kind of thing before either? |
Because it minimizes the chance that a many-core CPU grinds through most tests in X seconds, and one or two really long tests happened to get started at let's say X*0.8, extending the overall time to wait by another large fraction of X, while most cores are already idle. If the short and quick tests are left to the end, they can maximally utilize all of the cores all the way until all tests are done, therefore being quicker overall. It's a classic "packing problem" kind of thing... |
That is better when we expect tests to fail instead of pass, but generally in CI it's way more probable for the tests to pass. When running locally we might have different expectations, although I usually have a positive attitude and expect them to pass ;) |
By setting `is_slow = true`, a test may be marked as slow, which means that the duration of its execution is exceptionally long compared to other tests.
In order to minimize the duration of `cargo test`, slow tests should be executed at the beginning. This maximizes load on multithreaded CPUs by fully utilizing all threads and preventing late slow tests from stalling the whole suite.
By enabling the `fast` feature, slow tests are skipped. This is useful e.g. when someone wants to quickly run the test suite without waiting for a long time in order to roughly assess whether their changes broke something.
The option `sleep_to_meet_frame_rate` artificially increases the duration of tests in order to run at realtime speed.
This patch marks all tests which execute significantly longer than an average test with `is_slow = true`.
By setting
is_slow = true
, a test may be marked as slow, which means that the duration of its execution is exceptionally long compared to other tests.In order to minimize the duration of
cargo test
, slow tests should be executed at the beginning. This maximizes load on multithreaded CPUs by fully utilizing all threads and preventing late slow tests from stalling the whole suite.By enabling the
fast
feature, slow tests may be skipped. This is useful e.g. when someone wants to quickly run the test suite without waiting for a long time in order to roughly assess whether their changes broke something.fast
cargo test
cargo test -F imgtests
cargo nextest run
cargo nextest run -F imgtests
cargo nextest run --cargo-profile ci