Skip to content

Ship the Rust core with fat LTO and stripped symbols - #343

Merged
Alek99 merged 1 commit into
mainfrom
release-profile-fat-lto
Jul 27, 2026
Merged

Ship the Rust core with fat LTO and stripped symbols#343
Alek99 merged 1 commit into
mainfrom
release-profile-fat-lto

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What

Switches the release profile from thin to fat LTO and strips symbol tables from the shipped cdylib:

[profile.release]
lto = "fat"
codegen-units = 1
strip = true

Measured locally (Linux x86_64)

  • Binary size: 1.51 MB -> 1.29 MB (-15%), which shrinks every wheel since stripping happens at link time.
  • Runtime: no change on scripts/bench_scatter_native.py — 10M-point density prep reads 7.2–8.5 ms across repeats on both builds; run-to-run noise (±15%) dominates. CodSpeed on this PR is the cleaner verdict.
  • Build time: 11.6 s -> 13.2 s.
  • scripts/abi_smoke.py passes 140/140 against the stripped build — strip removes .symtab/debuginfo only, and .dynsym (what ctypes binds against) survives.

Deliberately not changed

  • panic stays unwind: the C-ABI backstop in lib.rs converts kernel panics into sentinel returns via catch_unwind; panic = "abort" would abort the embedding CPython process. The wasm target keeps its explicit -C panic=abort in release.yml, where unwinding is unsupported anyway.
  • No target-cpu bump: wheels stay baseline x86-64 (manylinux_2_17); AVX2 is already runtime-dispatched in src/simd.rs.
  • No PGO yet: recorded in spec/design/rust-engine.md §2 as an open lever needing per-target training workloads in the release matrix.

Spec updated (spec/design/rust-engine.md §2) with the profile, the measurements, and the panic constraint; changelog entry under Unreleased.

Summary by CodeRabbit

  • Performance

    • Reduced the shipped native library size by approximately 15%, from 1.51 MB to 1.29 MB.
    • Native scatter benchmark performance remains unchanged.
  • Documentation

    • Added documentation for release build settings and platform-specific panic-handling behavior.

Whole-program LTO plus strip cuts the cdylib ~15% (1.51 -> 1.29 MB); the
native scatter bench shows no runtime change beyond +/-15% run-to-run
noise. .dynsym survives stripping, so ctypes binding is unaffected
(abi_smoke passes 140/140 against the stripped build). panic stays
unwinding because lib.rs catches panics at the C ABI; the wasm target
keeps its explicit -C panic=abort in release.yml. Profile rationale and
the not-adopted PGO lever are recorded in spec/design/rust-engine.md.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Rust release profile now uses fat LTO, one codegen unit, and symbol stripping. Design documentation and the changelog record the panic-unwinding constraints and the resulting cdylib size reduction.

Changes

Rust release profile optimization

Layer / File(s) Summary
Release profile settings and documentation
Cargo.toml, spec/design/rust-engine.md, CHANGELOG.md
Release builds enable fat LTO, one codegen unit, and symbol stripping; documentation records FFI panic-unwinding requirements, binary-size results, and the changelog entry.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: alek99, masenf

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enabling fat LTO and stripping symbols in the Rust core release build.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-profile-fat-lto

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 73-76: Update the Rust core release-profile changelog entry to
document all three settings, including codegen-units = 1, and narrow the
stripping description to state that symbol tables are stripped while preserving
.dynsym. Match the terminology and rationale used in spec/design/rust-engine.md,
while retaining the size and benchmark results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: da24bbcc-af73-4a2c-875e-1170755eafcf

📥 Commits

Reviewing files that changed from the base of the PR and between c1233a3 and 867c887.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • Cargo.toml
  • spec/design/rust-engine.md

Comment thread CHANGELOG.md
Comment on lines +73 to +76
- The Rust core's release profile now uses fat LTO and strips symbol tables,
shrinking the shipped cdylib ~15% (1.51 → 1.29 MB) with no measured runtime
change on the native scatter bench (`spec/design/rust-engine.md` §2 records
the profile and why `panic` stays unwinding).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document all release-profile changes and narrow the stripping claim.

The implementation changes three profile settings, but this entry omits codegen-units = 1. “Strips symbol tables” is also broader than the specification, which says .dynsym is preserved. Please align the wording with spec/design/rust-engine.md.

Proposed wording
-- The Rust core's release profile now uses fat LTO and strips symbol tables,
+- The Rust core's release profile now uses fat LTO, one codegen unit, and
+  strips `.symtab`/debug information while preserving dynamic exports,
   shrinking the shipped cdylib ~15% (1.51 → 1.29 MB) with no measured runtime
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- The Rust core's release profile now uses fat LTO and strips symbol tables,
shrinking the shipped cdylib ~15% (1.51 → 1.29 MB) with no measured runtime
change on the native scatter bench (`spec/design/rust-engine.md` §2 records
the profile and why `panic` stays unwinding).
- The Rust core's release profile now uses fat LTO, one codegen unit, and
strips `.symtab`/debug information while preserving dynamic exports,
shrinking the shipped cdylib ~15% (1.51 → 1.29 MB) with no measured runtime
change on the native scatter bench (`spec/design/rust-engine.md` §2 records
the profile and why `panic` stays unwinding).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` around lines 73 - 76, Update the Rust core release-profile
changelog entry to document all three settings, including codegen-units = 1, and
narrow the stripping description to state that symbol tables are stripped while
preserving .dynsym. Match the terminology and rationale used in
spec/design/rust-engine.md, while retaining the size and benchmark results.

@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 103 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing release-profile-fat-lto (867c887) with main (c1233a3)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Alek99
Alek99 merged commit 4e11a66 into main Jul 27, 2026
28 checks passed
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.

2 participants