Link jsg-bench like the workerd binary so cross-language LTO applies to it #8790
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 418 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8790"
general
weight: 0.35
jasnell
Every
wd_cc_benchmarklinks like a test binary: on Linux, dynamically with one shared library percc_library, and withlinkopts_default, whose-Wl,--lto-O0turns off link-time optimization. So--config=cross-lto, whichdocs/benchmarking.mdrecommends, has no effect onbench-jsg. Nothing is inlined across the Rust/C++ boundary, each V8 call from Rust is several out-of-line calls, and the Rust/C++ ratios come out 2-6x larger than in a workerd binary built with cross-language LTO.In this patch
wd_cc_benchmarktakes atoolargument, following the convention inwd_rust_binary. Withtool = Truea benchmark links statically withlinkopts_tool, as the workerd binary does.bench-jsgsets it, and every other benchmark keeps its current linking, so CodSpeed baselines don't move. A new manualbench-reporttarget runs the benchmark on the test executor and keeps its JSON reports as test outputs. That makes remote measurement possible:bazel testnormally runs a benchmark only once as a dry run, and on macOS a remote build produces a Linux binary that can't run locally. The jsg-bench README documents the command, anddocs/benchmarking.mdexplains whentool = Trueis needed.| Case | C++ | Rust before | Rust after | Rust speedup | Rust/C++ before | Rust/C++ after |
|---|---:|---:|---:|---:|---:|---:|
| dispatch/noop | 11.9 ns | 31.8 ns | 12.6 ns | 2.5x | 2.38x | 1.05x |
| dispatch/raw | 11.7 ns | 84.0 ns | 15.4 ns | 5.5x | 6.06x | 1.33x |
| dispatch/u32 | 20.4 ns | 86.2 ns | 19.4 ns | 4.5x | 3.38x | 0.94x |
| union/number | 26.7 ns | 132.6 ns | 26.1 ns | 5.1x | 3.60x | 0.98x |
| optional/absent | 15.6 ns | 82.1 ns | 14.8 ns | 5.6x | 4.36x | 0.94x |
| property/proto-get | 22.0 ns | 49.5 ns | 23.1 ns | 2.1x | 1.98x | 1.04x |
| callback/reenter | 62.6 ns | 204.8 ns | 87.9 ns | 2.3x | 2.83x | 1.42x |
| resource/unwrap | 77.7 ns | 167.6 ns | 71.1 ns | 2.4x | 1.88x | 0.92x |
| resource/cached-wrap | 53.1 ns | 102.8 ns | 62.2 ns | 1.7x | 1.49x | 1.17x |
| resource/new-wrap | 266.8 ns | 537.5 ns | 319.6 ns | 1.7x | 1.78x | 1.21x |
| native/lifetime/0 | 36.0 ns | 87.0 ns | 52.7 ns | 1.7x | 2.10x | 1.47x |
| struct/pair-roundtrip | 296.3 ns | 604.8 ns | 331.6 ns | 1.8x | 1.94x | 1.12x |
| array/out/64 | 322.5 ns | 1098.6 ns | 459.0 ns | 2.4x | 3.10x | 1.48x |
| buffer/length/16 | 20.2 ns | 99.4 ns | 19.9 ns | 5.0x | 3.70x | 0.99x |
| string/in/ascii/16 | 75.9 ns | 133.8 ns | 57.2 ns | 2.3x | 1.64x | 0.74x |
| gc/allocate-collect/10000 | 3.10 ms | 6.08 ms | 3.79 ms | 1.6x | 1.73x | 1.23x |
| Fast API dispatch/noop | 7.3 ns | 28.4 ns | 18.4 ns | 1.5x | 3.39x | 2.55x |
CPU time per call. "Before" is a
--config=benchmarkbuild on main, and "after" is a--config=benchmark --config=cross-ltobuild with this patch. Both executables ran alternately on the same 4-vCPU x86-64 Linux executor, 3 processes of 5 repetitions each. The table shows the mean of two such runs, which agreed within 15% on every "after" ratio. The C++ column is the C++ time with this patch.The ratios still depend on compiler flags other than linking. With
-march=x86-64-v3and a lower ThinLTO import limit (-import-instr-limit=50), the median ratio was about 5% higher in two more runs, and the buffer cases were up to 1.5x higher because C++ gains more from AVX2. Only benchmark build files and docs change.