Skip to content
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

enable parallel codegen by default #17859

Closed
wants to merge 1 commit into from
Closed

enable parallel codegen by default #17859

wants to merge 1 commit into from

Conversation

spernsteiner
Copy link
Contributor

Enable parallel codegen (2 units) by default when --opt-level is 0 or 1. This gives a minor speedup on large crates (~10%), with only a tiny slowdown (~2%) for small ones (which usually build in under a second regardless). The current default (no parallelization) is used when the user requests optimization (--opt-level 2 or 3), and when the user has enabled LTO (which is incompatible with parallel codegen).

This commit also changes the rust build system to use parallel codegen when appropriate. This means codegen-units=4 for stage0 always, and also for stage1 and stage2 when configured with --release-channel=source. (Other release channel settings use codegen-units=1 for stage1 and stage2, to get maximum performance for release binaries.) The build system also sets codegen-units=1 for compiletest tests (compiletest does its own parallelization) and uses the same setting as stage2 for crate tests. The overall result (for release-channel=source) is 35% reduction in make all time, and 25% reduction in make check time.

r? @alexcrichton

Enable parallel codegen (2 units) by default when --opt-level is 0 or 1.  This
gives a minor speedup on large crates (~10%), with only a tiny slowdown (~2%)
for small ones (which usually build in under a second regardless).  The current
default (no parallelization) is used when the user requests optimization
(--opt-level 2 or 3), and when the user has enabled LTO (which is incompatible
with parallel codegen).

This commit also changes the rust build system to use parallel codegen when
appropriate.  This means codegen-units=4 for stage0 always, and also for stage1
and stage2 when configured with --release-channel=source.  (Other release
channel settings use codegen-units=1 for stage1 and stage2, to get maximum
performance for release binaries.)  The build system also sets codegen-units=1
for compiletest tests (compiletest does its own parallelization) and uses the
same setting as stage2 for crate tests.  The overall result is 35% reduction in
`make all` time, and 25% reduction in `make check` time.
@thestinger
Copy link
Contributor

Please don't make builds from source perform more poorly than they already do. This makes the language look very bad. Developers can be expected to pass a bunch of flags, expecting that of users and packagers is wrong. Only explicit debug builds should be using parallel code generation.

@thestinger
Copy link
Contributor

cc #17665, #17496

I'm strongly against doing this by default for builds of Rust though. Doing it for --opt-level=0 and --opt-level=1 is fine and I would r+ that myself.

@alexcrichton
Copy link
Member

This looks great, thanks @epdtry! In light of recent discussions about the "default mode" (see the issues @thestinger linked too), we're thinking that release mode should likely be the default instead of debug mode.

Until we have those flags implemented, could we hold off on the -C codegen-units=4 options for stage1/stage2? Otherwise I think all other changes here are unambiguously improvements!

@aturon
Copy link
Member

aturon commented Oct 15, 2014

It'd be really great to make progress here. @epdtry can you incorporate @alexcrichton's suggestion so we can go ahead and move forward?

@pcwalton pcwalton closed this Oct 21, 2014
@pcwalton
Copy link
Contributor

I'm taking this over.

lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 13, 2024
…=Veykril

fix: Correctly support `#[rustc_deprecated_safe_2024]`

Fixes rust-lang/rust-analyzer#17852
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants