-
Notifications
You must be signed in to change notification settings - Fork 14k
rustc_codegen_ssa: Make upstream monomorphizations representation sparse #149313
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?
rustc_codegen_ssa: Make upstream monomorphizations representation sparse #149313
Conversation
Upstream monomorphisations are a blessing and a curse of Zed's build performance. On one hand, we do benefit from it, as builds with share-generics disabled are slower for us (plus we don't really want to use nightly anyways). On the other, deserializing query results takes *a lot* of time. For some crates close to the end of our compilation pipeline, it's over 400ms per crate. To make matters worse, I've measured a hit ratio of upstream generics. A sample of such measurement goes as follows: ``` upstream_monomorphization returned None for 28501 distinct monomorphizations. upstream_monomorphization returned Some 2518 times. Results came from 163 distinct CrateNums. In total, there are 619731 instantiations ``` This is horrid for us, as we're using a very small percentage of the map that we spend so much time deserializing from. This commit tries to (rather clumsily) move us towards a sparse representation of upstream_monomorphizations. Instead of storing <DefId, (GenericArgsRef<'_>)> which is rather heavy to deserialize, we'll resort to storing Hashes of Instances. I plan to make this more foolproof, hence this commit is marked as WIP. For one, we should probably keep the projection queries. Also, it might be worthwhile to store index pointing at entry within exported_generics of target crate in order to remedy a potential for collisions. This commit reduces a `touch crates/editor/src/editor.rs` scenario in Zed for me from 14.5s to 11s.
That is a lot. I wonder if |
|
That's worth a try I guess. |
|
Looks like it indeed. And |
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
…mean, r=<try> rustc_codegen_ssa: Make upstream monomorphizations representation sparse
|
⌛ Trying commit c6d54c7 with merge 4fcb6e6… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/19674197107 |
Upstream monomorphisations are a blessing and a curse of Zed's build performance.
On one hand, we do benefit from it, as builds with share-generics disabled are slower for us (plus we don't really want to use nightly anyways).
On the other, deserializing query results takes a lot of time. For some crates close to the end of our compilation pipeline, it's over 400ms per crate.
To make matters worse, I've measured a hit ratio of upstream generics. A sample of such measurement goes as follows:
This is horrid for us, as we're using a very small percentage of the map that we spend so much time deserializing from.
This commit tries to (rather clumsily) move us towards a sparse representation of upstream_monomorphizations. Instead of storing <DefId, (GenericArgsRef<'_>)> which is rather heavy to deserialize, we'll resort to storing Hashes of Instances. I plan to make this more foolproof, hence this commit is marked as WIP.
For one, we should probably keep the projection queries. Also, it might be worthwhile to store index pointing at entry within exported_generics of target crate in order to remedy a potential for collisions.
This commit reduces a
touch crates/editor/src/editor.rsscenario in Zed for me from 14.5s to 11s.