Skip to content
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

ci: Run regression tests in random order #17961

Closed
wants to merge 1 commit into from

Conversation

torokati44
Copy link
Member

This is the primitive, chaotic neutral "little brother" of #15950, with the same motivation - to make Rust CI runs faster on average.

I do think that it would still make sense to sort the tests after shuffling, to bring the known slow ones forward - so, sorting only by kind, not by name.

To explain it by sticking to the packing problem analogy: this is basically shaking up (shuffling) the big bag (campaign) of little boxes (test cases), before packing (executing) them one by one into smaller backpacks (threads); this way, reducing the chance that some bigger boxes (slow tests) end up being packed too late, making all the backpacks too tall (waiting to finish), leaving some of them empty at the top (threads idling).

@torokati44 torokati44 added A-tests Area: Tests & Test Framework T-chore Type: Chore (like updating a dependency, it's gotta be done) labels Sep 17, 2024
@torokati44 torokati44 marked this pull request as draft September 17, 2024 12:05
@kjarosh
Copy link
Member

kjarosh commented Sep 17, 2024

Some benchmarks from my PC:

Order Average time (s)
by name 111
random 92.7 (-16.5%)
slow first 80.6 (-27.4%)

@kjarosh
Copy link
Member

kjarosh commented Sep 17, 2024

I guess the main issue I have with random order is that it's... random... at runtime at least. That way we're introducing indeterminism, as no two invocations will produce the same order (well... you know what I mean). It will be harder to reproduce and debug issues, tests will be less consistent and predictable, build can stop being reproducible. I believe that's also the reason why test execution frameworks generally do not run tests in random.

If test execution time is the main issue, I would recommend random, but predictable order. In particular, one can see ordering tests by their name as a kind of random (but predictable) order (because why by their names??), but it's just an exceptionally bad one in our case due to how tests are organized into directories. A better example would be sorting by hashes of test names or shuffling tests with a constant seed. That produces a random order which does not change each invocation.

@torokati44
Copy link
Member Author

Eh, you're right, this is silly. I just wanted to put it out there, to let it have an honest go... But no.

@torokati44 torokati44 closed this Sep 17, 2024
@torokati44
Copy link
Member Author

For future reference: It seems like nextest doesn't allow controlling the order in which the test cases are run:
https://github.com/nextest-rs/nextest/blob/a4490cdb039c28b321fef6b43a1b71a0af517999/nextest-runner/src/list/test_list.rs#L635

@torokati44
Copy link
Member Author

Also just noting this idea here, lest it may be forgotten: instead of completely random order, we could instead sort by a hash of kind+name(+seed/salt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tests Area: Tests & Test Framework T-chore Type: Chore (like updating a dependency, it's gotta be done)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants