Skip to content

Don't merge CGUs in incremental builds. #112441

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ where

debug_dump(tcx, "INITIAL PARTITIONING", &codegen_units);

// njn: update comment
// Merge until we have at most `max_cgu_count` codegen units.
// `merge_codegen_units` is responsible for updating the CGU size
// estimates.
{
if cx.tcx.sess.opts.incremental.is_none() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently -Ccodegen-units overrides the 256 default for incr comp. With this change that no longer happens. I think user's intent should be preserved even with incr comp. Maybe they care about runtime perf too and many codegen units is a huge regression (eg in a game) or maybe duplication of inlined functions costs more than not merging saves in reusable cgus. Either way the user should have the option to do what is best for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, as written I've done this too crudely. If this were to land various other changes would be needed, e.g. documentation. I have changed the PR to draft status to better reflect this.

let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_merge_cgus");
merge_codegen_units(cx, &mut codegen_units);
debug_dump(tcx, "POST MERGING", &codegen_units);
Expand Down