@samitouri / QOS-React-2 / commits / 7e71552e49

[rust-compiler] Add release profile: fat LTO, one codegen unit, strip (#36726)

The workspace has no `[profile.release]`, so the shipped napi binary (`index.node`) is built on stock cargo defaults with the symbol table retained: 11.2MB on arm64 macOS. Fat LTO + `codegen-units = 1` + `strip = true` lands at 7.2MB with no runtime cost. Release builds get slower; debug builds (`snap --rust`, the e2e harness) are unaffected. `profile-rust-port.ts --release` overrides `strip` so profiling runs keep symbol names. Measured (arm64 macOS, `cargo build --release -p react_compiler_napi`): | profile | size | |---|---| | defaults | 11.2MB | | this PR | 7.2MB | `opt-level = "s"` was measured and rejected: it cuts a further 2MB but costs ~50% compile throughput (3.9s to 5.85s median compiling 598 fixtures through the release CLI).

lauren committed Jun 9, 2026 at 15:38 UTC 7e71552e4924150e3a62837f060f0337b44c57d2
2 files changed +11 -1
compiler/Cargo.toml
+9
@@ -5,3 +5,12 @@ members = [
5 ]
6 resolver = "3"
7
8 +# Sizes the shipped napi binary (index.node). Measured on arm64 macOS:
9 +# default release is 11.2MB; fat LTO + one codegen unit + stripping symbols
10 +# lands at 7.2MB with no runtime cost. Release builds get slower; debug
11 +# builds (snap --rust, the e2e harness) are unaffected.
12 +[profile.release]
13 +lto = "fat"
14 +codegen-units = 1
15 +strip = true
16 +
compiler/scripts/profile-rust-port.ts
+2 -1
@@ -59,8 +59,9 @@ if (!jsonMode) {
59 );
60 }
61
62 +// Profiling needs symbol names; override the release profile's strip=true.
63 const cargoBuildArgs = releaseMode
63 - ? '--release -p react_compiler_napi'
64 + ? "--release --config 'profile.release.strip=false' -p react_compiler_napi"
65 : '-p react_compiler_napi';
66
67 try {