Skip to content

build: enable lto + codegen-units=1 for release profile#85

Open
iainmcgin wants to merge 2 commits intomainfrom
build/release-lto
Open

build: enable lto + codegen-units=1 for release profile#85
iainmcgin wants to merge 2 commits intomainfrom
build/release-lto

Conversation

@iainmcgin
Copy link
Copy Markdown
Collaborator

@iainmcgin iainmcgin commented Apr 29, 2026

Closes #60.

Adds lto = true and codegen-units = 1 to the workspace [profile.release].

Effect

Binary before after
protoc-gen-buffa ~3.9 MiB 3.08 MiB
protoc-gen-buffa-packaging ~706 KiB 529 KiB

Clean cargo build --release -p protoc-gen-buffa -p protoc-gen-buffa-packaging: ~10 s → ~27 s.

Scope

  • Applies to in-workspace release builds: CI-built GitHub Release binaries, benchmarks, conformance.
  • Does not apply to library consumers of buffa / buffa-build — Cargo only honors [profile.*] from the top-level workspace. The CHANGELOG entry calls this out.
  • Does not apply to cargo install protoc-gen-buffa — the workspace manifest isn't published. Adding per-crate [profile.release] to the plugin manifests was considered but produces a "profiles for the non root package will be ignored" warning on every workspace build. The guide's "Installing the protoc plugins" section now documents the CARGO_PROFILE_RELEASE_LTO=true CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 cargo install ... form instead.

Semver

Source-compatible change — no public-API impact.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@iainmcgin iainmcgin marked this pull request as ready for review April 29, 2026 22:45
@iainmcgin iainmcgin requested a review from kollektiv April 29, 2026 22:45
@iainmcgin iainmcgin enabled auto-merge (squash) April 29, 2026 22:45
@iainmcgin iainmcgin force-pushed the build/release-lto branch 2 times, most recently from 3f483df to 2196fc1 Compare May 2, 2026 17:40
Shrinks the prebuilt protoc-gen-buffa* release binaries by ~20% at the
cost of ~2x clean release-build time. Only the workspace root profile is
set (Cargo ignores per-crate profile sections inside a workspace, and the
warning noise outweighs the cargo-install benefit); the guide documents
the CARGO_PROFILE_RELEASE_LTO env-var path for cargo install users, and
the CHANGELOG notes that library consumers do not inherit this.
@iainmcgin iainmcgin force-pushed the build/release-lto branch from 2196fc1 to 3c905d6 Compare May 4, 2026 21:25
@iainmcgin iainmcgin requested a review from asacamano May 7, 2026 16:42
asacamano
asacamano previously approved these changes May 7, 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.

Enable Link-Time Optimization (LTO) and codegen-units = 1 for Release builds

3 participants