perf: optimize version script from rustc - #1355
Conversation
|
Actually this doesn't speed the things up that much. Did I miss something performance wise or just this doesn't provide any substantial speedup? EDIT: this actually is slower for compiling smaller libs like librustc_driver (although 300ms is probably too low to be a representative test) |
davidlattimore
left a comment
There was a problem hiding this comment.
That's unfortunate that there wasn't a speedup for librustc-driver. Although, I see a 9.9% speedup for the bevy dylib, which is still definitely something! I just looked at some profiles and it seems that analyze_glob_pattern is taking quite a bit of time.
I wonder if the changes you've made here would be a step towards moving the call to analyze_glob_pattern to run in parallel. e.g. we parse the file from a single thread, but don't identify the kinds of patterns, then from multiple threads, we classify matchers. I wouldn't suggest doing that in this PR, but we could explore doing it afterwards. If you don't want to, then I might.
|
If you don't want to regress performance in the short term, we could merge it into a new branch, do the optimizations, and then rebase main onto that branch (without squashing). |
|
The performance regression for librustc-driver was pretty small, about 1% and went away completely (at least for me) once the extra phase was run in parallel with dropping a bunch of Vecs. |
Sure, I will look into that when this is merged. |
| let mut per_symbol_flags = PerSymbolFlags::new(per_symbol_flags); | ||
|
|
||
| verbose_timing_phase!("Apply linker scripts"); | ||
| rayon::join( |
There was a problem hiding this comment.
We should probably benchmark that this doesn't slow things down when the version script isn't coming from rustc. I can do that tomorrow.
| for script in linker_scripts { | ||
| index.apply_linker_script(script); | ||
| } | ||
| { |
There was a problem hiding this comment.
Maybe we should move this scope out of the rayon task and only do the join if the version script is coming from rustc
There was a problem hiding this comment.
It's not clear to me which is better, this way we are always dropping in parallel but not sure that's actually worth it when the script isn't from rustc.
There was a problem hiding this comment.
rayon::join is pretty lightweight. It doesn't even heap-allocate the closures and we're not in a loop here, so this is one extra join during the entire linker execution.
This is great! The speedup is negligible on my system. Could you do the benchmark again on the latest revision? |
|
Sure! Still looks good to me: No significant change on librustc-driver. |
Fixes #1014.