-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Refactor the partitioning module to make it easier to introduce new algorithms #74275
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
981b094
to
42d7cf3
Compare
Let's make sure this doesn't hurt performance. @bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 42d7cf395b14b1b39b3050ffad364a1e15234f4a with merge 9b74ae087324a980952c4b760b1d7aab32b3ce65... |
|
||
use crate::monomorphize::partitioning::PreInliningPartitioning; | ||
|
||
pub fn merge_codegen_units<'tcx>( |
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.
I pulled this out into a separate module since it seemed like we might want a few different merge algorithms to choose from.
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.
I think this makes sense - I don't think it would prohibit us from having partitioning strategies which don't have a merging phase.
@@ -0,0 +1,433 @@ | |||
//! Partitioning Codegen Units for Incremental Compilation |
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 comment block is taken verbatim from its original location. Parts of it describe the partitioning process over all and parts are specific to the algorithm (now called DefaultPartitioner
).
This could probably be left as is for now but eventually we should split it into two parts and move the bits about the algorithm into module documentation for the DefaultPartitioner
algorithm.
target_cgu_count: usize, | ||
); | ||
|
||
fn place_inlined_mono_items( |
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 name & signature was taken from the existing code. One that that was not immediately obvious to me was that this does a lot more than just add copies of #[inline]
functions into CGUs. This function is primarily responsible for instantiating monomorphized functions in the modules that call them. (Perhaps that's what was meant by "inlined"?)
☀️ Try build successful - checks-actions, checks-azure |
Queued 9b74ae087324a980952c4b760b1d7aab32b3ce65 with parent 9d09331, future comparison URL. |
Finished benchmarking try commit (9b74ae087324a980952c4b760b1d7aab32b3ce65): comparison url. |
<0.1% speedup overall. |
r? @pnkfelix cc @rust-lang/wg-incr-comp |
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.
Current review comments notwithstanding, LGTM.
42d7cf3
to
6c7ab8d
Compare
Responded to review feedback so far. |
☔ The latest upstream changes (presumably #74214) made this pull request unmergeable. Please resolve the merge conflicts. |
6c7ab8d
to
2acd149
Compare
☔ The latest upstream changes (presumably #74091) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Sorry but I had to change this option's structure.
2acd149
to
ee88fc1
Compare
Rebased. @pnkfelix if you are interested in doing the review, I don't mind waiting for that, otherwise we can find someone else from wg-incr-comp to do the review. |
This will allow us to prototype different partitioning schemes without adding a lot of extra conditionals everywhere.
ee88fc1
to
98b943e
Compare
@pnkfelix I rebased and split out the trait into the first commit. The second commit has no functional changes, just moving the code into a new module. |
internalization_candidates, | ||
} = initial_partitioning; | ||
|
||
let single_codegen_unit = initial_cgus.len() == 1; |
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.
Viewing in diff mode with whitespace changes hidden is a huge win here. :)
@bors r+ |
📌 Commit 98b943e has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
@bors treeclosed- |
☀️ Test successful - checks-actions, checks-azure |
Three of the four methods in `DefaultPartitioning` are defined in `default.rs`. But `merge_codegen_units` is defined in a separate module, `merging`, even though it's less than 100 lines of code and roughly the same size as the other three methods. (Also, the `merging` module currently sits alongside `default`, when it should be a submodule of `default`, adding to the confusion.) In rust-lang#74275 this explanation was given: > I pulled this out into a separate module since it seemed like we might > want a few different merge algorithms to choose from. But in the three years since there have been no additional merging algorithms, and there is no mechanism for choosing between different merging algorithms. (There is a mechanism, `-Zcgu-partitioning-strategy`, for choosing between different partitioning strategies, but the merging algorithm is just one piece of a partitioning strategy.) This commit merges `merging` into `default`, making the code easier to navigate and read.
I've split the
librustc_mir::monomorphize::partitioning
module into a few files and introduced aPartitioner
trait which allows us to decouple the partitioning algorithm from the code which integrates it into the query system. This should allow us to introduce new partitioning algorithms much more easily. I've also gone ahead and added a-Z
flag to control which algorithm is used (currently there is only thedefault
).I left a few comments in places where things might be improved further.
r? @pnkfelix cc @rust-lang/wg-incr-comp