perf(benchmark): enable pureFunctions for production bundle benches#14558
perf(benchmark): enable pureFunctions for production bundle benches#14558hardfist wants to merge 2 commits into
Conversation
📦 Binary Size-limit
❌ Size increased by 4.00KB from 67.73MB to 67.74MB (⬆️0.01%) |
Merging this PR will improve performance by 6.77%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
|
@codspeed explain why threejs production no change |
Why the threejs production benchmark shows no changeShort answer: explicitly enabling The trace: In this PR the production benchmark variant sets it explicitly ( builder.mode(Mode::Production);
builder.devtool(rspack::builder::Devtool::SourceMap);
builder.experiments(Experiments::builder().css(true).pure_functions(true));But the builder already derives the default from the mode ( pure_functions: d!(self.pure_functions, _production),where That's exactly the behavior the new Takeaways:
Summary
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
|
@codspeed explain why bundle@basic-react-production-sourcemap and bundle@threejs-production-sourcemap are faster |
Why
|
| Benchmark | Base | Head | Change |
|---|---|---|---|
rust@create_named_chunk_ids |
3 ms | 2.8 ms | +6.82% |
rust@create_chunk_ids |
3.2 ms | 3 ms | +6.72% |
bundle@basic-react-production-sourcemap (~142 ms) and bundle@threejs-production-sourcemap (~192 ms) both register as unchanged.
Why the bundle benches don't move
This is consistent with the earlier explanation for threejs: toggling pure_functions on these production variants is effectively a no-op for the work being measured. pure_functions already defaults to true in production mode, so enabling it explicitly resolves to the identical CompilerOptions. I also compared the enable commit against the newer chore: disable pure function commit directly, and the bundle benchmarks still don't move — so even flipping the flag has no measurable cost/benefit on these fixtures. A flat result is the expected outcome.
Why the two chunk-id benchmarks "improved"
That +6.7% is almost certainly run-to-run jitter, not a real speedup:
create_chunk_ids/create_named_chunk_idsare among the shortest simulation benchmarks (~3 ms). Their hot path lives entirely inrspack_idsandrspack_corechunk-graph code, and leans heavily on rayon parallel iterators — so sub-~7% swings are typical noise.- This PR only touches the benchmark harness (
pure_functionssetters/tests) — it doesn't change any chunk-id or chunk-graph code, so there's no mechanism for it to speed up these stages. - The same ~6.7% delta shows up whether I compare against
mainor against the PR's own earlier commit, which is the signature of variance on these noise-prone benches rather than a change introduced by the PR.
Takeaway: the production-sourcemap bundle benches are correctly reported as flat, and the chunk-id "improvement" is noise. If you want to actually measure the impact of pure_functions, you'd need a dedicated variant comparing pure_functions(false) against the production default to isolate the cost of the pure-call tree-shaking analysis.
Summary
- Warming up the performance wizard...
- Investigating benchmark changes — Confirmed the production-sourcemap bundle benchmarks are unchanged; only noise-prone chunk-id stage benchmarks moved
- Handling comment — Comment handling finished successfully
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.
Summary
ExperimentsBuilder::pure_functionssetter on the Rust builder sidepure_functionsexplicitly for production sourcemap bundle benchmarkspure_functionsdefaults to production/undefined mode, matching the JS default behaviorValidation
cargo fmt -p rspack -p rspack_benchmarkpnpm run build:binding:devcargo test -p rspack pure_functions_defaults_follow_modeandcargo check -p rspack_benchmark --bencheswere started after rebasing onto latestorigin/main, then stopped when requested to open the draft PR directly.