-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve tests and benchmarks for slice::sort and slice::sort_unstable #42882
Conversation
@bors: r+ Thanks! |
📌 Commit 12205f1 has been approved by |
⌛ Testing commit 12205f1 with merge 32091e1b39664ecd81d82276c1ce000e8a5c75b2... |
💔 Test failed - status-travis |
Looks like a legitimate failure?
|
The failure is apparently due to a codegen bug on ARM platforms. I believe simply moving |
@stjepang yeah sounds good to me! |
All right, let's see if it works this time... |
@bors: r+ |
📌 Commit 723833f has been approved by |
The new failures are spurious, it seems... three targets were not tested at all (they're marked with |
@stjepang Don't worry about the |
@bors rollup |
…ches, r=alexcrichton Improve tests and benchmarks for slice::sort and slice::sort_unstable This PR just hardens the tests and improves benchmarks. More specifically: 1. Benchmarks don't generate vectors in `Bencher::iter` loops, but simply clone pregenerated vectors. 2. Benchmark `*_strings` doesn't allocate Strings in `Bencher::iter` loops, but merely clones a `Vec<&str>`. 3. Benchmarks use seeded `XorShiftRng` to be more consistent. 4. Additional tests for `slice::sort` are added, which test sorting on slices with several ascending/descending runs. The implementation identifies such runs so it's a good idea to test that scenario a bit. 5. More checks are added to `run-pass/vector-sort-panic-safe.rs`. Sort algorithms copy elements around a lot (merge sort uses an auxilliary buffer and pdqsort copies the pivot onto the stack before partitioning, then writes it back into the slice). If elements that are being sorted are internally mutable and comparison function mutates them, it is important to make sure that sort algorithms always use the latest "versions" of elements. New checks verify that this is true for both `slice::sort` and `slice::sort_unstable`. As a side note, all of those improvements were made as part of the parallel sorts PR in Rayon (nikomatsakis/rayon#379) and now I'm backporting them into libcore/libstd. r? @alexcrichton
@bors r- This failed the rollup, with I think the same failure. Possibly will be fixed after the LLVM update, not sure.
|
It will be fixed after the update, yes. |
Ok, LLVM has been updated. Should I rebase now? |
@bors: r+ Nah should still apply cleanly! |
📌 Commit 723833f has been approved by |
…xcrichton Improve tests and benchmarks for slice::sort and slice::sort_unstable This PR just hardens the tests and improves benchmarks. More specifically: 1. Benchmarks don't generate vectors in `Bencher::iter` loops, but simply clone pregenerated vectors. 2. Benchmark `*_strings` doesn't allocate Strings in `Bencher::iter` loops, but merely clones a `Vec<&str>`. 3. Benchmarks use seeded `XorShiftRng` to be more consistent. 4. Additional tests for `slice::sort` are added, which test sorting on slices with several ascending/descending runs. The implementation identifies such runs so it's a good idea to test that scenario a bit. 5. More checks are added to `run-pass/vector-sort-panic-safe.rs`. Sort algorithms copy elements around a lot (merge sort uses an auxilliary buffer and pdqsort copies the pivot onto the stack before partitioning, then writes it back into the slice). If elements that are being sorted are internally mutable and comparison function mutates them, it is important to make sure that sort algorithms always use the latest "versions" of elements. New checks verify that this is true for both `slice::sort` and `slice::sort_unstable`. As a side note, all of those improvements were made as part of the parallel sorts PR in Rayon (nikomatsakis/rayon#379) and now I'm backporting them into libcore/libstd. r? @alexcrichton
☀️ Test successful - status-appveyor, status-travis |
This PR just hardens the tests and improves benchmarks.
More specifically:
Bencher::iter
loops, but simply clone pregenerated vectors.*_strings
doesn't allocate Strings inBencher::iter
loops, but merely clones aVec<&str>
.XorShiftRng
to be more consistent.slice::sort
are added, which test sorting on slices with several ascending/descending runs. The implementation identifies such runs so it's a good idea to test that scenario a bit.run-pass/vector-sort-panic-safe.rs
. Sort algorithms copy elements around a lot (merge sort uses an auxilliary buffer and pdqsort copies the pivot onto the stack before partitioning, then writes it back into the slice). If elements that are being sorted are internally mutable and comparison function mutates them, it is important to make sure that sort algorithms always use the latest "versions" of elements. New checks verify that this is true for bothslice::sort
andslice::sort_unstable
.As a side note, all of those improvements were made as part of the parallel sorts PR in Rayon (nikomatsakis/rayon#379) and now I'm backporting them into libcore/libstd.
r? @alexcrichton