Skip to content

Reduce release binary size#7

Merged
koba-e964 merged 4 commits into
mainfrom
codex/executable-size-reduction
Jul 6, 2026
Merged

Reduce release binary size#7
koba-e964 merged 4 commits into
mainfrom
codex/executable-size-reduction

Conversation

@koba-e964

@koba-e964 koba-e964 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace anyhow with a small project-local error type
  • switch release opt-level from z to s based on measurement
  • preserve panic behavior, symbols, crypto, KDF, compression, and data formats
  • tighten executable-size CI limits after confirming cross-platform headroom

Local size result

  • before: 675552 bytes
  • after: 598064 bytes
  • delta: -77488 bytes

Cross-platform CI size result

Platform main PR Delta
Linux 768480 bytes 682552 bytes -85928 bytes
macOS 676032 bytes 598048 bytes -77984 bytes
Windows 476672 bytes 458240 bytes -18432 bytes

Ambient CI info

Platform Runner image OS rustc Host LLVM cargo Size limit
Linux ubuntu-24.04 (20260628.225.1) Ubuntu 24.04.4 LTS rustc 1.96.0 (ac68faa20 2026-05-25) x86_64-unknown-linux-gnu 22.1.2 cargo 1.96.0 (30a34c682 2026-05-25) 725000 bytes
macOS macos-26-arm64 (20260630.0213.1) macOS 26.4 25E246 rustc 1.96.0 (ac68faa20 2026-05-25) aarch64-apple-darwin 22.1.2 cargo 1.96.0 (30a34c682 2026-05-25) 650000 bytes
Windows windows-2025-vs2026 (20260628.158.1) Windows Server 2025 10.0.26100 Datacenter rustc 1.96.0 (ac68faa20 2026-05-25) x86_64-pc-windows-msvc 22.1.2 cargo 1.96.0 (30a34c682 2026-05-25) 500000 bytes

Validation

  • cargo fmt --check
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo test --locked
  • cargo build --release
  • cargo bloat --release --crates
  • cargo bloat --release
  • PR executable-size matrix passes on Linux, macOS, and Windows with tightened limits
  • executable-size CI logs include rustc/cargo versions for each platform

koba-e964 added 4 commits July 6, 2026 07:52
Why:
- The release executable carried avoidable size from anyhow and the previous size optimization setting.
- The binary-size CI matrix tracks platform limits, so keeping the artifact smaller gives more headroom.

What:
- Replace anyhow with a small project-local string-backed error type and context helpers.
- Keep existing bail/ensure-style validation through local macros.
- Switch release opt-level from z to s after measurement showed a smaller local artifact.

Impact:
- Local macOS release binary changed from 675552 bytes to 598064 bytes, saving 77488 bytes.
- No data format, crypto, KDF, or compression behavior changes.
- Verified with cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked, cargo build --release, and cargo bloat --release.

Prompt:
- Find ways to decrease executable size using cargo bloat at discretion.
Why:
- The PR should include the research, plan, and implementation checklist that guided the executable-size reduction.

What:
- Add the task-scoped codex notes for research, plan, and feature validation.

Impact:
- No runtime behavior changes.
- Notes document the constraints, rejected options, measurements, and completed validation.

Prompt:
- Include the notes in the executable-size reduction PR.
Why:
- The executable-size reduction creates enough headroom to enforce stricter CI limits.

What:
- Lower Linux, macOS, and Windows release executable size thresholds.

Impact:
- No runtime behavior changes.
- CI now fails earlier on binary-size regressions.
- Limits retain headroom over observed PR sizes: Linux 682552, macOS 598048, Windows 458240.

Prompt:
- If the size decreased that much, you can make the size limits stricter.
Why:
- Executable-size comparisons need ambient compiler context, especially rustc version.

What:
- Print rustc --version --verbose and cargo --version --verbose in each executable-size matrix job before building.

Impact:
- No runtime behavior changes.
- CI logs now capture compiler/tool versions for Linux, macOS, and Windows size measurements.

Prompt:
- Need to include ambient info. rustc version is necessary.
@koba-e964
koba-e964 merged commit 8f9ddc9 into main Jul 6, 2026
4 checks passed
@koba-e964 koba-e964 added this to the v0.2.0 milestone Jul 6, 2026
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