From 2423f591b000fb7289dee44af66cb9a1ef4b6bfc Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 27 Apr 2022 12:51:26 +1000 Subject: [PATCH] change(rust): Use link-time optimisation in release builds (#4184) * Move Rust optimisations to Cargo.toml Previously they were in the Dockerfile, so they only applied to those builds. * Use link-time optimisation in release builds * Retry after log ssh failures in full sync test Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.toml | 12 ++++++++++++ docker/Dockerfile | 6 ------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bd248f148ab..801570789ef 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 f2e034a2b30..55f7e5f488e 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