libtest: never iterate over all tests in --exact mode - #161868
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
33e044a to
ffc55d6
Compare
--exact mode
This comment has been minimized.
This comment has been minimized.
|
I am not sure what is going on with rustdoc. Even with Also I noticed the test closures rustdoc uses for the "standalone" codepath rely on their |
|
Didn't look but isn't it a bootstrap issue? |
|
I don't know. I'm not sure what the expected behavior even is. It may be a download-rustc problem. I'm now trying with that turned off. |
93e6cbb to
70ce450
Compare
|
Okay, I think rustdoc should compile again. We'll see if I adjusted the auto-generated code correctly, that's harder to test.^^ The "standalone" codepath has extra overhead now, there's some more cloning. My understanding is that the "merged" codepath is the preferred one so I hope that's fine. |
842218d to
83fdcbd
Compare
|
|
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
83fdcbd to
616df7f
Compare
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
616df7f to
1277df4
Compare
|
cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for 29adbb8 failed: CI. Failed job:
|
|
There's no error visible in that log, it just cuts off at some point. @bors retry |
…uwer Rollup of 12 pull requests Successful merges: - #160911 (Remove d32 feature from 32-bit Arm targets) - #161868 (libtest: never iterate over all tests in `--exact` mode) - #162771 (Filter do_not_recommend impls before handling a single candidate) - #162779 (rustdoc: Revert "fix bare urls split text") - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint) - #161612 (std: make a lot of items crate private) - #162204 (Suggest keyword order for `extern "C" const unsafe fn`) - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate) - #162638 (dont suggest changing the mutability of a borrow that comes from a macro) - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths) - #162654 (Improve Armv7-R documentation) - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
|
@bors try jobs=dist-x86_64-msvc |
|
⌛ Trying commit cae9fb4 with merge f3337a8… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/34948086607 |
libtest: never iterate over all tests in `--exact` mode try-job: dist-x86_64-msvc
Rollup merge of #161868 - RalfJung:libtest-less-alloc, r=Mark-Simulacrum libtest: never iterate over all tests in `--exact` mode This should help with rust-lang/miri#5013: When running `cargo miri nextest`, nextest spawns one Miri instance for each test of the crate. If the crate has a lot of tests, a non-trivial amount of time is spent in the test harness before it even starts running the test. Turns out almost half that time is spent just making copies of all the `TestDescAndFn`. That seems silly, we have a perfectly fine static array of those sitting around in the code generated by `--test` expansion, let's just use references to that array. So this changes the `TestList` used to represent the unfiltered list of tests to use borrowed rather than owned types. That changes ripples outwards. The entry points used by the `--test` harness remain mostly unchanged (except that I renamed them as the old name did not make sense), but rustdoc has been using the old fully-owned API. Rustdoc has two codepaths, "standalone" and "merged". - For "merged", the fix is easy -- like the `--test` harness, this can just generate a static array full of `StaticTestFn` rather than populating a `Vec` at runtime. - For "standalone", things are more tricky. We need to construct an `&[&TestDescAndFn]`, which requires filling a new vector with references to the entries of an existing `Vec<TestDescAndFn>`. This also fundamentally relies on the support for dynamic test functions in libtest. Those must now always be cloneable, so they are now internally stored in `Arc` and must be `Fn`, not `FnOnce`. So compared to before there's now one more big `Vec` to fill with references to all tests, as well as some `Arc::clone`. OTOH this mode runs a full separate process for each test so I doubt this extra cost is noticeable. The alternative is to keep support for `FnOnce` dynamic tests in libtest, which is highly non-trivial due to having to plumb multiple layers of `Cow`-like handling through everything. I don't think it's worth it, given that dynamic tests are only used by "standalone" rustdoc and by the tests testing libtest. Overall this saves more than 1s when running coretests (which has 2787 tests) with a hot incremental cache with `--exact char::test_is_numeric`. Before: 7.606s After: 6.484s Given that most of that time is actually spent in rustc, not in the interpreter, that is a very big speedup for the interpreter part.
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run |
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…k-Simulacrum libtest: never iterate over all tests in `--exact` mode This should help with rust-lang/miri#5013: When running `cargo miri nextest`, nextest spawns one Miri instance for each test of the crate. If the crate has a lot of tests, a non-trivial amount of time is spent in the test harness before it even starts running the test. Turns out almost half that time is spent just making copies of all the `TestDescAndFn`. That seems silly, we have a perfectly fine static array of those sitting around in the code generated by `--test` expansion, let's just use references to that array. So this changes the `TestList` used to represent the unfiltered list of tests to use borrowed rather than owned types. That changes ripples outwards. The entry points used by the `--test` harness remain mostly unchanged (except that I renamed them as the old name did not make sense), but rustdoc has been using the old fully-owned API. Rustdoc has two codepaths, "standalone" and "merged". - For "merged", the fix is easy -- like the `--test` harness, this can just generate a static array full of `StaticTestFn` rather than populating a `Vec` at runtime. - For "standalone", things are more tricky. We need to construct an `&[&TestDescAndFn]`, which requires filling a new vector with references to the entries of an existing `Vec<TestDescAndFn>`. This also fundamentally relies on the support for dynamic test functions in libtest. Those must now always be cloneable, so they are now internally stored in `Arc` and must be `Fn`, not `FnOnce`. So compared to before there's now one more big `Vec` to fill with references to all tests, as well as some `Arc::clone`. OTOH this mode runs a full separate process for each test so I doubt this extra cost is noticeable. The alternative is to keep support for `FnOnce` dynamic tests in libtest, which is highly non-trivial due to having to plumb multiple layers of `Cow`-like handling through everything. I don't think it's worth it, given that dynamic tests are only used by "standalone" rustdoc and by the tests testing libtest. Overall this saves more than 1s when running coretests (which has 2787 tests) with a hot incremental cache with `--exact char::test_is_numeric`. Before: 7.606s After: 6.484s Given that most of that time is actually spent in rustc, not in the interpreter, that is a very big speedup for the interpreter part.
…oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#160911 (Remove d32 feature from 32-bit Arm targets) - rust-lang/rust#161868 (libtest: never iterate over all tests in `--exact` mode) - rust-lang/rust#162771 (Filter do_not_recommend impls before handling a single candidate) - rust-lang/rust#162779 (rustdoc: Revert "fix bare urls split text") - rust-lang/rust#161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint) - rust-lang/rust#161612 (std: make a lot of items crate private) - rust-lang/rust#162204 (Suggest keyword order for `extern "C" const unsafe fn`) - rust-lang/rust#162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate) - rust-lang/rust#162638 (dont suggest changing the mutability of a borrow that comes from a macro) - rust-lang/rust#162643 (Fix `path_trailing_sep` methods for Windows verbatim paths) - rust-lang/rust#162654 (Improve Armv7-R documentation) - rust-lang/rust#162784 (AGENTS.md: Permit local experimentation, per the online policy.)
Rollup merge of #162796 - RalfJung:libtest-no-early-exit, r=oli-obk libtest: do not early exit from test runners Suggested by @Mark-Simulacrum in #161868. I finally figured out why my earlier attempts did not work.
View all comments
This should help with rust-lang/miri#5013:
When running
cargo miri nextest, nextest spawns one Miri instance for each test of the crate. If the crate has a lot of tests, a non-trivial amount of time is spent in the test harness before it even starts running the test. Turns out almost half that time is spent just making copies of all theTestDescAndFn. That seems silly, we have a perfectly fine static array of those sitting around in the code generated by--testexpansion, let's just use references to that array.So this changes the
TestListused to represent the unfiltered list of tests to use borrowed rather than owned types. That changes ripples outwards. The entry points used by the--testharness remain mostly unchanged (except that I renamed them as the old name did not make sense), but rustdoc has been using the old fully-owned API.Rustdoc has two codepaths, "standalone" and "merged".
--testharness, this can just generate a static array full ofStaticTestFnrather than populating aVecat runtime.&[&TestDescAndFn], which requires filling a new vector with references to the entries of an existingVec<TestDescAndFn>. This also fundamentally relies on the support for dynamic test functions in libtest. Those must now always be cloneable, so they are now internally stored inArcand must beFn, notFnOnce. So compared to before there's now one more bigVecto fill with references to all tests, as well as someArc::clone. OTOH this mode runs a full separate process for each test so I doubt this extra cost is noticeable.The alternative is to keep support for
FnOncedynamic tests in libtest, which is highly non-trivial due to having to plumb multiple layers ofCow-like handling through everything. I don't think it's worth it, given that dynamic tests are only used by "standalone" rustdoc and by the tests testing libtest.Overall this saves more than 1s when running coretests (which has 2787 tests) with a hot incremental cache with
--exact char::test_is_numeric.Before: 7.606s
After: 6.484s
Given that most of that time is actually spent in rustc, not in the interpreter, that is a very big speedup for the interpreter part.