next.js
45f4b19c - Store the Turbopack module cache in a Map (#98947)

Commit
13 days ago
Store the Turbopack module cache in a Map (#98947) Maps are faster than Objects for map-like usecases such as the module cache The one complexity is `require.cache` which exposes the module cache as an object, this however is an extremely rare usecase, so we support it via a runtime module that re-exposes the module cache as an Object using a `Proxy`. ### Performance Measured with `bench/module-cost` Module **execution** time — the phase that actually hits the cache: | measurement | obj | map | delta | 95% CI | rel | | --- | --- | --- | --- | --- | --- | | client commonjs | 13.60 ms | 13.00 ms | **−0.60 ms** | [−0.65, −0.30] | −4.4% | | pages api commonjs | 21.59 ms | 20.64 ms | **−0.95 ms** | [−1.39, −0.74] | −4.4% | | pages api esm | 33.24 ms | 32.55 ms | **−0.69 ms** | [−1.06, −0.47] | −2.1% | | client esm | 20.55 ms | 20.60 ms | +0.05 ms | [−0.25, +0.30] | noise | Caveat: this benchmark is a deep require chain that deliberately slams this codepath, so this really just confirms the claim that Maps are faster and this is relevant to the bundled codepaths. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
Parents
Loading