Skip to content

perf: switch release builds to Thin LTO - #464

Merged
Mohamed Mansour (mohamedmansour) merged 1 commit into
microsoft:mainfrom
mohamedmansour:mohamedmansour-thin-lto
Aug 21, 2026
Merged

perf: switch release builds to Thin LTO#464
Mohamed Mansour (mohamedmansour) merged 1 commit into
microsoft:mainfrom
mohamedmansour:mohamedmansour-thin-lto

Conversation

@mohamedmansour

Copy link
Copy Markdown
Contributor

Motivation

Full LTO (lto = true) in the release profile delivers maximum cross-crate optimization but at a steep cold-build-time cost. This PR switches the release profile to Thin LTO (lto = "thin"), which still performs cross-crate LTO (unlike lto = false/no LTO, or per-codegen-unit "thin local" LTO) but with a faster, more parallelizable linking pipeline. codegen-units = 1 is retained so cross-crate inlining and optimization opportunities are not reduced by unit fragmentation.

This is a standalone follow-up scoped strictly to the LTO mode itself — no CI matrix, SDK, platform-support, packaging, macOS/Windows, README, or DESIGN.md changes are included.

Changes

  1. Cargo.toml: [profile.release] lto = true -> lto = "thin" (keeps codegen-units = 1, panic = "abort", strip = true unchanged).
  2. .github/copilot-instructions.md: updated the release-profile code snippet and surrounding prose to accurately describe Thin LTO instead of full LTO.
  3. xtask/src/main.rs: updated the benchmark-validation step's comment referencing lto = true to lto = "thin", and adjusted the accompanying explanation of why the bench-profile smoke test is skipped in favor of the dev profile.

Measured results (release build, this environment)

Metric Full LTO (true) Thin LTO ("thin") Delta
Cold release build time 123.789s 67.479s -45.5%
Canonical Render/1000 (criterion) 31.218us 27.075us -13.3%
RenderFAST/1000 (criterion) 1.2949ms 0.9803ms -24.3%
Rendered output bytes unchanged unchanged 0%
CLI binary size 5,717,504 B 6,585,344 B +15.2%
Node addon size 1,873,408 B 1,984,512 B +5.9%
FFI binary size 641,536 B 641,536 B unchanged
Python extension size 771,072 B 771,072 B unchanged

Takeaways:

  • Cold release build time is nearly halved, which meaningfully speeds up local --release iteration and CI release builds.
  • Runtime performance in the canonical render and fast-render benchmarks actually improved with Thin LTO in this measurement, rather than regressing — Thin LTO is not simply "less optimization," and cross-crate inlining decisions can differ in ways that help these particular hot paths.
  • Rendered output bytes are unchanged, confirming no behavioral/output difference from the LTO mode change.
  • Binary size grows modestly for the CLI (+15.2%) and Node addon (+5.9%), likely from different inlining/code-layout decisions under Thin LTO; FFI and Python artifact sizes are unaffected.

Validation

  • cargo xtask check (license-headers, fmt, clippy, deny, test, build, build (wasm), build (examples), bench (validate), docs) passes cleanly on this branch.
  • Confirmed the branch is rebased on latest origin/main with 0 commits ahead/behind at the merge-base, and contains no cross-compilation-related changes.
  • Confirmed the diff touches exactly the three files described above (Cargo.toml, .github/copilot-instructions.md, xtask/src/main.rs) — no CI matrix, SDK, platform-support, packaging, macOS/Windows, README, or DESIGN.md changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mohamedmansour
Mohamed Mansour (mohamedmansour) merged commit d3d9221 into microsoft:main Aug 21, 2026
24 checks passed
@mohamedmansour
Mohamed Mansour (mohamedmansour) deleted the mohamedmansour-thin-lto branch August 21, 2026 21:28
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.

3 participants