[Perf]: SplitChunks repeats full-graph work after chunk-graph reuse on hot rebuilds
Expected and actual
When a watch edit leaves all splitting inputs unchanged, reuse a validated split result instead of repeating equivalent optimization. Currently, chunk-graph construction can be reused while SplitChunks still prepares modules and processes extraction groups again. The synthetic Node fixture below demonstrates that distinction; it does not implement a cache.
Reproduction
Download the fixture and results. Save its package.json and run.mjs in a new directory:
npm install
node run.mjs --out run-min0 --min-size 0 --features 64One Node entry dynamically imports 64 features sharing 128 payload modules and a dependency-free leaf. The runner performs three real watch builds: initial, a constant-length leaf edit, and restoration. It executes every async import and checks the changed/restored values. No application code, Router, browser or server is needed.
The executed run used Node 22.15.1, Linux x64, Rsbuild 2.2.8 and Rspack 2.2.6, with an existing installation—not a validated fresh registry install. Configuration uses development mode, async-only splitting, minSize0 and incremental chunk-graph reuse; persistent cache, minification, source maps and HMR are disabled. Validation details contain exact loaded JS/native hashes, effective settings, timeouts and complete results.
Result
Times are milliseconds. optimize chunks includes other optimizer work; its child timers are not additive.
| Build | Build chunk graph | Reconstruction callback | optimize chunks | SplitChunks: process groups |
|---|---|---|---|---|
| initial | 1.196 | 0.917 | 2.243 | 2.067 |
| edit | 0.498 | absent | 2.428 | 2.285 |
| restore | 0.514 | absent | 2.945 | 2.763 |
The cold build establishes logger coverage. The hot builds omit the construction callback's timer, while SplitChunks timers remain. This is source-backed evidence of construction reuse, not a public cache-hit boolean. Missing required timers or a hot reconstruction fails the runner. Both edits executed correctly; restoration and compiler close passed.
A separate same-graph minSize10000 run reduced optimization time but increased emitted bytes from 246,391 to 519,015; observed hot compiler totals rose from 11–12 to 17–18 ms. This small comparison establishes no general performance gain.
Historical impact: a July 13 private candidate observed 0.81–1.40 seconds in SplitChunks after construction reuse, but its runtime/version provenance was incomplete. This new fixture establishes the mechanism only, not that duration.
Cache boundary
IncrementalArtifacts restores a pre-optimization graph. Simply skipping optimization would lose extraction. A separate successful post-optimization snapshot is a possible approach; restoring the final compilation graph risks stale runtime/emission state.
Topology alone is insufficient: changed module sizes, splitting options or export/runtime usage can change extraction. Unknown callback/plugin inputs and failed or superseded work need fallback. Measure snapshot cost and test size-threshold crossings, dependency changes and successive updates before treating this as a safe cache design.
Source: web-infra-dev/rspack