Skip to content

perf(build): shrink release binaries via strip + thin LTO#12

Merged
jaredLunde merged 1 commit into
mainfrom
optimize-release-profile
Jun 30, 2026
Merged

perf(build): shrink release binaries via strip + thin LTO#12
jaredLunde merged 1 commit into
mainfrom
optimize-release-profile

Conversation

@jaredLunde

Copy link
Copy Markdown
Contributor

What

Tune [profile.release]: strip = true, lto = "thin", codegen-units = 1.

Binary Before After Cut
beyond-ai (gateway) 21.5 MB 14.0 MB −35%
beyond-ai-agent (agent) 11.6 MB 8.3 MB −28%

Why these and not others

  • No runtime coststrip only drops debug symbols; thin LTO + a single codegen unit optimize across the crate graph and typically improve throughput, so they fit "performance is a feature" rather than trading against it.
  • opt-level stays at 3. opt-level = "z"/"s" and panic = "abort" are deliberately avoided — they'd hurt a throughput-sensitive proxy / change worker-panic isolation.
  • strip also shrinks the Docker image (the Dockerfile builds with this profile), so no Dockerfile change is needed.

Cost: slower release builds (the agent went ~20s → ~32s locally; gateway similar).

Single-file change (Cargo.toml).

🤖 Generated with Claude Code

Tune [profile.release]: strip = true, lto = "thin", codegen-units = 1.
These cut binary size with no runtime cost — thin-LTO + a single codegen
unit typically improve throughput too, so they're aligned with the perf
ethos, not against it. opt-level stays at 3; opt-level "z"/"s" and
panic = "abort" are deliberately avoided (they'd hurt the throughput-
sensitive proxy / change worker-panic isolation).

Sizes (release):
  beyond-ai (gateway):  21.5 MB -> 14.0 MB  (-35%)
  beyond-ai-agent:      11.6 MB ->  8.3 MB  (-28%)

strip also shrinks the Docker image (it builds with this profile), so no
Dockerfile change is needed. Cost: slower release builds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jaredLunde jaredLunde merged commit 27dc4a2 into main Jun 30, 2026
1 check passed
@jaredLunde jaredLunde deleted the optimize-release-profile branch June 30, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant