diff --git a/Cargo.toml b/Cargo.toml index bd248f14..80157078 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,18 @@ opt-level = 1 [profile.release] panic = "abort" +# Speed up release builds and sync tests using link-time optimization. +# Some of Zebra's code is CPU-intensive, and needs extra optimizations for peak performance. +# +# TODO: +# - add "-Clinker-plugin-lto" in .cargo/config.toml to speed up release builds +# - add "-Clinker=clang -Clink-arg=-fuse-ld=lld" in .cargo/config.toml +# - also use LTO on C/C++ code: +# - use clang to compile all C/C++ code +# - add "-flto=thin" to all C/C++ code builds +# - see https://doc.rust-lang.org/rustc/linker-plugin-lto.html#cc-code-as-a-dependency-in-rust +lto = "thin" + [patch.crates-io] # TODO: replace with upstream librustzcash when these changes are merged (#3037) diff --git a/docker/Dockerfile b/docker/Dockerfile index f2e034a2..55f7e5f4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -42,12 +42,6 @@ RUN if [ "$(uname -m)" != "aarch64" ]; then \ && \ rm -rf /var/lib/apt/lists/* /tmp/* -# Optimize builds. In particular, regenerate-stateful-test-disks.yml was reaching the -# GitHub Actions time limit (6 hours), so we needed to make it faster. -# -# TODO: apply this optimisation level to all release builds in .cargo/config.toml -ENV RUSTFLAGS "-C opt-level=3" - ENV CARGO_HOME /app/.cargo/ # Build dependencies - this is the caching Docker layer! RUN cargo chef cook --release --features enable-sentry --recipe-path recipe.json