-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Improve Rust compile times #6065
Comments
Benchmarked
|
Ran the same scripts on the same CPU again, but on current
|
This enables `cargo` to parallelize the library and binary builds internally, reducing the Rust build time by the build time of the binaries (because they are overall faster than the library build). Part of zcash#6065.
Hmm, I had Avenues for improvement:
|
I forgot to mention that I obtained the above figures by adding the |
I tried using diff --git a/src/Makefile.am b/src/Makefile.am
index 0e21d2d44c..daecbe9832 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -139,7 +139,7 @@ LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SHANI)
endif
cargo-build: $(CARGO_CONFIGURED) $(LIBSECP256K1)
- $(rust_verbose)$(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) $(cargo_verbose)
+ $(rust_verbose)$(RUST_ENV_VARS) RUSTC_BOOTSTRAP=1 $(CARGO) rustc $(RUST_BUILD_OPTS) $(cargo_verbose) --lib -- -Z self-profile -Z self-profile-events=default,args
cargo-build-lib: cargo-build
Here's what I get on my Ryzen 9 5950X (also with a Oof, that's a lot of time doing linking! And about half of it is LTO: Lines 111 to 112 in feec543
It turns out that It uses a bunch more threads (the timeline scrolls off down to a thread number of 196), and saves over 20s of compile time. Some of the durations for comparison (in seconds):
|
This should achieve similar performance gains to "fat" LTO (which we were previously using) while taking substantially less time to run (over 20s saved on a Ryzen 9 5950X). Part of zcash#6065.
I tried combining #6407 with removing
|
We should check that this doesn't break determinism of the gitian builds. |
This moves us back to using the default value of 16 for the release profile (which does not enable incremental builds). Part of zcash#6065.
@ebfull told me that the original motivation here was performance; he seems to recall that the compiler at the time could produce faster code if all codegen was in a single unit. We should check there are no significant performance regressions caused by #6411 (or if there are, decide if they are worth the compile time improvements). |
Currently we spend quite a bit of time recompiling Rust when making incremental changes. It would be nice to figure out how to improve this. Ideas for improvement:
codegen-units = 1
.The text was updated successfully, but these errors were encountered: