From 4c953731c4ea06ecce1a6f1e0229f1dc18a967ff Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 15 Oct 2025 22:45:20 -0400 Subject: [PATCH] release: finally switch to LTO for release binaries There seems to be a modest improvement on some workloads: ``` $ time rg -co '\w+' sixteenth.txt 158520346 real 8.457 user 8.426 sys 0.020 maxmem 779 MB faults 0 $ time rg-lto -co '\w+' sixteenth.txt 158520346 real 8.200 user 8.178 sys 0.012 maxmem 778 MB faults 0 ``` I've somewhat reversed course on my previous thoughts here. The improvement isn't much, but the hit to compile times in CI isn't terrible. Mostly I'm doing this out of "good sense," and I think it's generally unlikely to make it more difficult for me to diagnose performance problems. (Since I still use the default `release` profile locally, since it's about an order of magnitude quicker to compile.) Ref #325, Ref #413, Ref #1187, Ref #1255 --- .github/workflows/release.yml | 6 +++--- Cargo.toml | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 298356b0..b11550ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -176,11 +176,11 @@ jobs: - name: Build release binary shell: bash run: | - ${{ env.CARGO }} build --verbose --release --features pcre2 ${{ env.TARGET_FLAGS }} + ${{ env.CARGO }} build --verbose --profile release-lto --features pcre2 ${{ env.TARGET_FLAGS }} if [[ "${{ matrix.os }}" == windows-* ]]; then - bin="target/${{ matrix.target }}/release/rg.exe" + bin="target/${{ matrix.target }}/release-lto/rg.exe" else - bin="target/${{ matrix.target }}/release/rg" + bin="target/${{ matrix.target }}/release-lto/rg" fi echo "BIN=$bin" >> $GITHUB_ENV diff --git a/Cargo.toml b/Cargo.toml index baeac1bd..5c2ada43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,12 +86,8 @@ panic = "abort" incremental = false codegen-units = 1 -# This is the main way to strip binaries in the deb package created by -# 'cargo deb'. For other release binaries, we (currently) call 'strip' -# explicitly in the release process. [profile.deb] -inherits = "release" -debug = false +inherits = "release-lto" [package.metadata.deb] features = ["pcre2"]