-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Get rid of niche selection's dependence on fields's order #130508
Conversation
This comment has been minimized.
This comment has been minimized.
I don't think largest niche in the largest variant is necessarily optimal. There may be multiple largest variants. And niches in a smaller variant can still be useful, e.g. when used by an outer enum when nesting multiple into each other. The linked issue could be solved by sorting the enum variant fields differently, without changing the niche-picking code. |
My wording is not precise. I don't quite understand the relevance of niches in smaller variant. My commit still uses the same largest variant as before. |
The field sorting is quite naive compared to what's implemented in |
The Miri subtree was changed cc @rust-lang/miri |
Thanks for adjusting the Miri test!
The intention in that Miri test was that the add(0) would be changed to add(size-of-ptr) if the padding moves elsewhere. Maybe it would make sense to add a "let pad_offset = ...;" and "add(pad_offset)" to make that more clear.
|
I was thinking of different logic, not
For the non-prefixed enum layout it should actually be going through the same logic as univariant structs. It's calling So yeah, the sorting was already fine. As you spotted, it wasn't making use of the already-optimized niche choice when multiple of the same size were available. I think there would be ways to make the miri test more robust by inferring the position of the padding by enumerating all fields and the struct size. But that's probably overkill for an easily adjusted test. And the layout logic only changes every now and then. LGTM. @bors r+ |
and niches can affect perf @bors rollup=never |
…, r=the8472 Get rid of niche selection's dependence on fields's order Fixes rust-lang#125630. Use the optimal niche selection decided in `univariant()` rather than picking niche field manually. r? `@the8472`
☀️ Test successful - checks-actions |
👀 Test was successful, but fast-forwarding failed: 422 Update is not a fast forward |
Bors met race condition. It seems that a |
Finished benchmarking commit (902f295): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary -0.6%, secondary -0.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (secondary 0.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 769.206s -> 769.235s (0.00%) |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (2b11f26): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary 1.1%, secondary 1.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (secondary 0.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 768.639s -> 769.323s (0.09%) |
@rustbot label: +perf-regression-triaged |
Fixes #125630.
Use the optimal niche selection decided in
univariant()
rather than picking niche field manually.r? @the8472