Skip to content

perf(core): cache loadBundle stats projection - #8343

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/perf-environment-stats-cache
Aug 22, 2026
Merged

chenjiahan merged 1 commit into
mainfrom
chenjiahan/perf-environment-stats-cache

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

Loading different entries from the same compilation currently serializes the same stats subset for every entry. This PR caches that projection in a WeakMap keyed by Stats, avoiding repeated toJson calls while allowing previous compilations to be garbage-collected.

Performance

Benchmark using a real Rspack Stats from a 50-entry compilation on Node.js v24.12.0 (darwin-arm64), with 10 warmups and 30 samples:

Median P95
Before 35.199 ms 37.803 ms
After 1.018 ms 1.125 ms
Delta -34.181 ms (-97.1%) -36.678 ms (-97.0%)

The number of stats projections per sample drops from 50 to 1. This measures only the stats projection stage, not complete bundle execution.

@chenjiahan
chenjiahan merged commit f1afbf7 into main Aug 22, 2026
7 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/perf-environment-stats-cache branch August 22, 2026 04:05
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.

1 participant