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>
This commit is contained in:
teor 2022-04-27 12:51:26 +10:00 committed by GitHub
parent d164c75f48
commit 2423f591b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -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)

View File

@ -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