-
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
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc) #106977
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 5185c3f658c566a8a55ccb27b335169cdedc7ad9 with merge de6228c8f8104f4bed1e7fb6b1874f3531c6aa31... |
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (de6228c8f8104f4bed1e7fb6b1874f3531c6aa31): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never 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)ResultsThis 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.
CyclesResultsThis 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.
|
1142d90
to
285e2c1
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 285e2c1be2918f18fcec3386f91ab8cebe3d19dc with merge 587656503f974defd16cf67c0f3894dcc9d7b565... |
☀️ Try build successful - checks-actions |
285e2c1
to
57ee1bb
Compare
@rust-timer build 587656503f974defd16cf67c0f3894dcc9d7b565 |
This comment has been minimized.
This comment has been minimized.
57ee1bb
to
72ee14c
Compare
Finished benchmarking commit (587656503f974defd16cf67c0f3894dcc9d7b565): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never 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)ResultsThis 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.
CyclesResultsThis 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.
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
Performance looks OK now, I think. r? compiler (see MCP 533 for background information) |
let mut items: Vec<(&K, &V)> = self.inner.iter().collect(); | ||
if cache_sort_key { | ||
items.sort_by_cached_key(|(k, _)| k.to_stable_hash_key(hcx)); | ||
} else { | ||
items.sort_unstable_by_key(|(k, _)| k.to_stable_hash_key(hcx)); | ||
} | ||
items.into_iter().map(|(_, v)| v) |
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.
This is a recurring pattern, maybe give it a helper?
It should at least have documentation what cache_sort_key
does
@bors r+ |
Thanks for the review, @oli-obk! |
☀️ Test successful - checks-actions |
Finished benchmarking commit (005fc0f): 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)ResultsThis 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. |
rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)` Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept. cc rust-lang#106977
rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)` Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept. cc rust-lang#106977
@michaelwoerister perf got slightly worse from the original perf run, but it's still enough of a wash that I don't think it needs investigating. @rustbot label +perf-regression-triaged |
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc) This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble. The changes required are moderate but non-zero: - In some places the collections are extracted into sorted vecs. - There are a few instances where for-loops have been changed to extends. ~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~ Performance does not seem to be negatively affected ([perf-run here](rust-lang/rust#106977 (comment))). Part of [MCP 533](rust-lang/compiler-team#533). r? `@ghost`
This PR changes the
rustc_data_structures::define_id_collections!
macro to useUnordMap
andUnordSet
instead ofFxHashMap
andFxHashSet
. This should account for a large portion of hash-maps being used in places where they can cause trouble.The changes required are moderate but non-zero:
Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.Performance does not seem to be negatively affected (perf-run here).
Part of MCP 533.
r? @ghost