From c21ae08f0af88b7a72423ebf49108504eec27081 Mon Sep 17 00:00:00 2001 From: Mohamed Mansour Date: Fri, 21 Aug 2026 13:07:34 -0700 Subject: [PATCH] perf: switch release builds to Thin LTO Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 4 ++-- Cargo.toml | 2 +- xtask/src/main.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index a97e0adf6..79dca1335 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -220,7 +220,7 @@ The workspace ships with an aggressive release profile (`Cargo.toml`): ```toml [profile.release] -lto = true # Full link-time optimization +lto = "thin" # Thin link-time optimization codegen-units = 1 # Maximum optimization (slower compile) panic = "abort" # No unwinding - smaller binary, but panics terminate immediately strip = true # Strip debug symbols @@ -228,7 +228,7 @@ strip = true # Strip debug symbols - **`panic = "abort"` means panics kill the process instantly** - reinforcing why `unwrap`/`expect` are banned in library code. - Always validate performance claims in `--release` mode. Debug builds are not representative. -- Be aware that LTO + single codegen unit makes release builds slow. Use `cargo test` (debug) for iteration, `cargo build --release` for final validation. +- Thin LTO with a single codegen unit keeps cross-crate optimization while reducing release build time compared with full LTO. Use `cargo test` (debug) for iteration, `cargo build --release` for final validation. --- diff --git a/Cargo.toml b/Cargo.toml index 9caf9fce3..7940a0049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,7 +111,7 @@ unnecessary_box_returns = "deny" unsafe_code = "deny" [profile.release] -lto = true +lto = "thin" codegen-units = 1 panic = "abort" strip = true diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 44c6ff05e..e1ba68c56 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -669,12 +669,12 @@ impl Step { run: || { // Use the dev profile (not the default bench profile) for the // criterion `--test` smoke run. The bench profile inherits the - // release profile's `lto = true, codegen-units = 1`, which spends - // ~40s compiling the full graph just to assert criterion's + // release profile's `lto = "thin", codegen-units = 1`, which still + // compiles the full optimized graph just to assert criterion's // `--test` entry point runs once. The dev profile reuses the // already-built unit-test artifacts and finishes in seconds. Real // benchmark measurements (via `cargo xtask bench`) continue to - // use the unchanged bench profile so their numbers stay accurate. + // use the release-derived bench profile so their numbers stay accurate. run_command_quiet( "cargo", &[