-
Notifications
You must be signed in to change notification settings - Fork 13.3k
improve cgu schedule with greedy partition #112766
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
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit c2ea570 with merge 4b3f9c2e29e1cc79fdc77597dbbe2cf8db1c5bfa... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (4b3f9c2e29e1cc79fdc77597dbbe2cf8db1c5bfa): 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.
Binary sizeResultsThis 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.
Bootstrap: 656.258s -> 658.359s (0.32%) |
cc @nnethercote as I believe they have tried a greedy partitioning recently. It also seems this PR removes the minimum CGU size property added in #112448, and part of the regressions may be coming from losing what that PR gained. |
I have been working on improving CGU handling for several weeks. It's a difficult problem and many things that you might expect to improve performance do not. In particular, the interplay between walltime (speed), max-rss (memory use), and binary size is challenging -- it's hard to improve one or more of these across multiple benchmarks without badly regressing others. Some PRs that may be of interest:
There is a function If you want to continue working on this, we should coordinate, perhaps on Zulip. |
Thanks for your reviews and I did read the previous great PRs. If I understood @nnethercote‘s greedy approach right, they tried to merge as much as possible. While I’m implementing one of the algorithm for multi-way number partition problems to ease the size diff between cgu, unfortunately the perf said llvm opt pass was unexpectedly slower 🥲 And I wasn’t intended to remove the MIN const, because the partition count must be known from the beginning in my approach, while MIN applied to the loop process “dynamically”, so I just commented it out for a experiment. |
#111712 implemented a greedy approach. It gave much better results than the current algorithm in terms of making the CGU sizes more similar. But it resulted in worse compile-time speed. One reason for this is that the size estimates are not very good. So if you have, for example, 10 CGUs of equal estimated size but one of those estimates is too small by 30%, then you'll end up with one CGU that takes 30% longer than the other to compile -- that's the "long pole" that's holding everything up. In contrast, a worse merge might leave you with 10 CGUs of varying size, which leaves more room to accommodate inaccuracies. E.g. most of the smaller CGUs can have their size underestimated without it hurting much. There are a lot of surprising behaviours here. I recommend using a profiler like the self-profiler or samply that can show thread execution, because seeing how long the different codegen threads take is very helpful. For example, this screenshot is from samply: |
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #112695) made this pull request unmergeable. Please resolve the merge conflicts. |
benchmarked locally, it regressed. |
The difference between merged cgu should be more smaller than the old code which merges the small cgus into less-small cgu.
r? @bjorn3 may I have a perf-run? thanks :)