From 929944198ca8b88539254543500c3d3d1d8db630 Mon Sep 17 00:00:00 2001 From: Aloke Desai Date: Tue, 28 Apr 2026 17:20:51 -0500 Subject: [PATCH] Shrink binary size for the standalone oz cli (#9301) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Reduces the `oz` CLI tarball size by adapting two techniques the WASM build already uses for the standalone CLI artifact. **Measured results**: | Platform | Before (gzipped) | After (gzipped) | Reduction | |---|---|---|---| | macOS aarch64 | ~120 MiB | ~48 MiB | **~−60%** | | Linux x86_64 | 121.5 MiB | ~49 MiB | **~−60%** | There are two primary changes: 1. No longer bundle any of the async assets into the headless binary (this drops ~57 MiB of incompressible PNG/JPG bytes from the binary) 2. Introduce a `release-ci` profile that uses `opt-level = s` and `lto = fat`. This mirrors the release profile we use on wasm. For the CLI specifically, this should be a no-op for user-perceived latency: `oz agent run` is wall-clock-dominated by network round-trips to the LLM API and file I/O, not by CPU-bound inner loops. The 5–15% slowdown that `-Os` typically incurs on tight numeric loops is invisible next to a multi-second model response, and a smaller binary actually loads faster on cold start. ## Agent Mode - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode ## Changelog Entries for Stable CHANGELOG-OZ: Reduced the `oz` CLI tarball download size by ~60% on both macOS and Linux. --------- Co-authored-by: Oz --- Cargo.toml | 15 +++++++++++++++ app/src/lib.rs | 8 +++++++- script/linux/bundle | 12 ++++++++++-- script/macos/bundle | 12 ++++++++++-- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f16d2e4c..3b499172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -453,6 +453,21 @@ debug-assertions = true [profile.rltoda] inherits = "release-lto-debug_assertions" +# A profile tuned for the `oz` CLI tarball. The CLI is shipped over the network +# and run headlessly, so we trade some compile time and a small amount of +# runtime perf for a smaller binary by mirroring the size-leaning settings used +# by `release-wasm`. +[profile.release-cli] +inherits = "release-lto" +opt-level = "s" +codegen-units = 1 + +# A custom CLI release-like profile that forces debug assertions on, used for +# dev/local channel CLI bundles. +[profile.release-cli-debug_assertions] +inherits = "release-cli" +debug-assertions = true + [profile.release-wasm] inherits = "release" opt-level = "s" diff --git a/app/src/lib.rs b/app/src/lib.rs index b65346d9..e110566e 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -311,7 +311,13 @@ use warpui::{AppContext, SingletonEntity, WindowId}; #[folder = "assets"] #[include = "bundled/**"] // Should be kept in sync with BUNDLED_ASSETS_DIR. #[include = "async/**"] // Should be kept in sync with ASYNC_ASSETS_DIR. -#[cfg_attr(target_family = "wasm", exclude = "async/**")] // Excludes take precedence. +#[cfg_attr(target_family = "wasm", exclude = "async/**")] +// Excludes take precedence. +// Standalone CLI builds (the `oz` tarball) are headless and never render the +// onboarding/theme imagery in `async/`, so we exclude those bytes from the +// embedded asset set to keep the CLI binary small — mirroring the carve-out +// already applied for the WASM target above. +#[cfg_attr(feature = "standalone", exclude = "async/**")] pub struct Assets; pub static ASSETS: Assets = Assets; diff --git a/script/linux/bundle b/script/linux/bundle index b0bb75a7..55261264 100755 --- a/script/linux/bundle +++ b/script/linux/bundle @@ -118,9 +118,17 @@ elif [[ $RELEASE_CHANNEL = "local" || $RELEASE_CHANNEL = "dev" ]]; then # For dev bundles, we want to enable debug assertions to # catch violations that would otherwise silently pass in # a normal release build (e.g. in stable). - CARGO_PROFILE="release-lto-debug_assertions" + if [[ "$ARTIFACT" == "cli" ]]; then + CARGO_PROFILE="release-cli-debug_assertions" + else + CARGO_PROFILE="release-lto-debug_assertions" + fi else - CARGO_PROFILE="release-lto" + if [[ "$ARTIFACT" == "cli" ]]; then + CARGO_PROFILE="release-cli" + else + CARGO_PROFILE="release-lto" + fi fi if [[ "$CARGO_PROFILE" == "dev" ]]; then diff --git a/script/macos/bundle b/script/macos/bundle index 567f39e7..096bdd7b 100755 --- a/script/macos/bundle +++ b/script/macos/bundle @@ -250,9 +250,17 @@ elif [[ $RELEASE_CHANNEL = "local" || $RELEASE_CHANNEL = "dev" ]]; then # For dev bundles, we want to enable debug assertions to # catch violations that would otherwise silently pass in # a normal release build (e.g. in stable). - CARGO_PROFILE="release-lto-debug_assertions" + if [[ "$ARTIFACT" == "cli" ]]; then + CARGO_PROFILE="release-cli-debug_assertions" + else + CARGO_PROFILE="release-lto-debug_assertions" + fi else - CARGO_PROFILE="release-lto" + if [[ "$ARTIFACT" == "cli" ]]; then + CARGO_PROFILE="release-cli" + else + CARGO_PROFILE="release-lto" + fi fi TARGET_PROFILE_DIR="$CARGO_PROFILE"