-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
layout: Store inverse memory index in FieldsShape::Arbitrary
#150116
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
base: main
Are you sure you want to change the base?
Conversation
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
This comment has been minimized.
This comment has been minimized.
c3ca7dc to
8db435e
Compare
|
huh. I wonder what it's inverted relative to? |
This comment has been minimized.
This comment has been minimized.
|
@moulins I have no objection to the substance of the change but "inverse" suggests a relativeness this doesn't capture... IMO this is still just a "memory index" until you do something like specify the other half of the pair, whether it's the key or value, at which point they might adopt a logical ordering.
|
|
kinda curious if this has any effect on perf or if it's just logical cleanup @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
layout: Store inverse memory index in `FieldsShape::Arbitrary`
Hm, good point... what about |
|
something like that sounds good to me! |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ed52dc8): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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. @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 1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 481.694s -> 485.432s (0.78%) |
| FieldsShape::Arbitrary { memory_index, .. } => { | ||
| for idx in Self::aggregate_field_iter(memory_index) { | ||
| FieldsShape::Arbitrary { inverse_memory_index, .. } => { | ||
| for idx in Self::aggregate_field_iter(inverse_memory_index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If iterating in memory order is now cheap, maybe we should just always do that... in fact that could unlock a bunch of follow-up cleanup here. Probably best to make all that a follow-up PR, but a good indication that this PR moves us in the right direction. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you'd propose removing aggregate_field_iter entirely and and simply iterate the fields directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But I would suggest doing it in a separate PR so we can separately benchmark that change.
8db435e to
e0bc269
Compare
This comment has been minimized.
This comment has been minimized.
|
Renamed EDIT: I just noticed that rust-analyzer has its own version of |
|
@moulins I don't think this type is related in a meaningful way? https://github.com/rust-lang/rust/blob/main/src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs#L519 Do you mean something else? |
|
To be clear, I am 100% certain that rust-analyzer uses |
|
You're totally right; from what I can see, the uses are here in |
All usages of `memory_index` start by calling `invert_bijective_mapping`, so storing the inverted mapping directly saves some work and simplifies the code.
e0bc269 to
b31ee3a
Compare
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
All usages of
memory_indexstart by callinginvert_bijective_mapping, so storing the inverted mapping directly saves some work and simplifies the code.