From 6c61e366a36906e60fb1122cb32e9685601ad112 Mon Sep 17 00:00:00 2001 From: Jared Lunde Date: Tue, 30 Jun 2026 10:33:16 -0700 Subject: [PATCH] perf(build): shrink release binaries via strip + thin LTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- Cargo.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d22c422..55b5471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,15 @@ unimplemented = "deny" # size/count never goes unnoticed. Profiles only take effect at the workspace root. [profile.release] overflow-checks = true +# Size + speed (no runtime cost): `strip` drops debug symbols (also shrinks the Docker image, which +# builds with this profile); `lto = "thin"` and `codegen-units = 1` optimize across the whole crate +# graph and typically *improve* throughput too — so they fit "performance is a feature", not against +# it. The price is slower release builds. `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 = true +lto = "thin" +codegen-units = 1 # Shared dependency versions. Members opt in with `.workspace = true`, so the version is pinned # once for the whole tree. Only deps used (or expected to be used) by more than one crate live here;