-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Fix parallel rustc not being reproducible due to unstable sorts of items #144576
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
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Fix parallel rustc not being reproducible due to unstable sorts of items
I don't think this is a proper fix. Multiple items can have the exact same span. And ignoring all spans is valid too. Try ordering based on the Edit: Never mind. That code is actually intended to keep a stable order based on the source location across rustc versions. Maybe only do the sorting based on span when doing codegen tests would be a good idea? I also think span order comparison could be non-deterministic with parallel rustc once we do parallel macro expansion as that can cause the source map order to be non-deterministic. |
You are right. I agree that using span only for codegen tests is a good idea, but we need a brief way to enable/disable it. An environment variable or flag? |
Also A hash would make a completely different order that is unrelated to the source order. Maybe is it confusing? |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (2e20b9f): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 4.7%, secondary 4.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 20.0%, secondary 4.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 465.115s -> 468.017s (0.62%) |
I guess that parallel macro expansion should not affect the order of source maps? We may confirm this with @petrochenkov . In this pr's sorting, |
Could we stop sorting altogether? We would rely on the order output by the collector, which should be deterministic. Probably far from source order, but deterministic. |
The key is codegen tests need a predictive and deterministic order. |
Should we adapt the tests or restrict sorting to codegen tests? |
I prefer to adapt the tests, but it may need more effort and process. A more ideal resolution is to avoid regressions in sorting. |
030a674
to
f7fba9a
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Fix parallel rustc not being reproducible due to unstable sorts of items
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (e972d15): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 4.4%, secondary 2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 24.9%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 468.885s -> 468.757s (-0.03%) |
We collect items in parallel (here), so the order is not deterministic. However, during the collecting, we have already obtained |
I'm aware of the simpler way to add a flag to enable sorting(by |
Hey, all. I have open a new PR to solve it. See #144722 please. We add a new internal option to only enable sorting for codegen tests, which doesn't influence the normal path. |
Currently, A tuple
(DefId, SymbolName)
is used to determine the order of items in the final binary. HoweverDefId
is expected as non-deterministic, which leads to some not reproducible issues under parallel compilation. (See #140425 (comment))Here, we use
Span
replacingDefId
to make the order deterministic.Items generated by a macro have a same span. But for codegen tests, items are expected the same order between in binary and source. Unluckily,
SymbolName
isn't predictive. So we useDefPath
to distinguish items generated by a same macro.At the cost of it, we have to manually sort items generated by macros for codegen tests.
This PR is purposed to fix #140425, but seemly works on #140413 too.
This behavior hasn't added into any test until we have a test suit for the parallel frontend. (See #143953)
Update #113349
r? @oli-obk
cc @matthiaskrgr @Zoxc @SparrowLii