Resolver: Parallelize the import resolution loop#158845
Resolver: Parallelize the import resolution loop#158845LorrensP-2158466 wants to merge 3 commits into
Conversation
|
Lets see what CI says. I have tried to add comments to changes to show my thought process behind them, but i'll make another pass here as well to be sure. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
17bd1cb to
9aa1069
Compare
This comment has been minimized.
This comment has been minimized.
9aa1069 to
a45ba86
Compare
|
@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.
…r=<try> Resolver: Parallelize the import resolution loop
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…r=<try> Resolver: Parallelize the import resolution loop
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ba4d109): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf 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 -3.9%, secondary -2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 491.257s -> 490.757s (-0.10%) |
|
|
|
I think that the main bottlenecks are the following (that i notice):
|
…chenkov Resolver: Wrap arenas in `WorkerLocal` In preperation of parallel import resolution rust-lang/rust#158845 this pr wraps the resolver arenas in `WorkerLocal` to ensure we don't need any synchronization to access an arena. This is common in the compiler. Also, when building the resolution table of an external module, we first create a seperate table and fill that one, after which we replace the empty table with that new table. (Prep Work for rust-lang/rust#158845) And a manual inline of `define_extern`. r? @petrochenkov
|
For reference, an attempt to make |
…tions, r=petrochenkov Resolver: extract `use_injections` out of main `Resolver` Prep work for rust-lang#158845. Extract the `use_injections` field out of the resolver and into the `LateResolutionVisitor`. It can then be passed into the `report_errors` pass, so no behaviour is changed. This allows the `Resolver` to be `DynSync`, see rust-lang#158845 (comment). r? @petrochenkov
Ooh, I could try to finish that work. |
…tions, r=petrochenkov Resolver: extract `use_injections` out of main `Resolver` Prep work for rust-lang#158845. Extract the `use_injections` field out of the resolver and into the `LateResolutionVisitor`. It can then be passed into the `report_errors` pass, so no behaviour is changed. This allows the `Resolver` to be `DynSync`, see rust-lang#158845 (comment). r? @petrochenkov
Rollup merge of #159339 - LorrensP-2158466:extract-use-injections, r=petrochenkov Resolver: extract `use_injections` out of main `Resolver` Prep work for #158845. Extract the `use_injections` field out of the resolver and into the `LateResolutionVisitor`. It can then be passed into the `report_errors` pass, so no behaviour is changed. This allows the `Resolver` to be `DynSync`, see #158845 (comment). r? @petrochenkov
[WIP] Benchmarking for the parallel import resolution PR #158845
I'll do some additional benchmarking in #159387. |
|
The results in #159387 are good, basically we can land that whole PR without making the final change enabling |
|
Will do! But I must say that I find it weird that it works in multi threaded compilation. The reason for changing it to Why does it work now? (Note that I am on my phone, so I could have missed something, but I am curious) |
Because the |
I see it now 😅. I assume that we will keep this one blocked until we have something for the |
View all comments
Parallelize the import resolution loop using
par_filter_map(introduced in this pr).With the accompanying changes to make datastructures concurrent:
Onceto ensure only 1 thread builds the table and all others wait if they need itThis is the bare minimum to make the parallel loop work and is not at all optimized, this will follow :).
r? @petrochenkov