Extends the cache-hit work from PR #481 with additional hot-path wins that
don't change public behavior or semantics:
- UnsafeCachePlugin.getCacheId: build the cache id by direct string concat
with a `\0` separator instead of `JSON.stringify`ing a 6-key object per
lookup. Paths, requests, queries and fragments produced by parseIdentifier
never contain raw `\0`; context is still JSON-stringified when included,
which escapes any `\0` there.
- util/path.isRelativeRequest: char-code-based check that replaces the
`/^\.\.?(?:\/|$)/` regex used in UnsafeCachePlugin and getInnerRequest.
- DescriptionFileUtils.cdUp: single reverse char-code scan instead of two
`lastIndexOf` calls (POSIX strings don't need to be fully re-scanned for
a backslash that isn't there).
- DescriptionFilePlugin: skip the global-regex backslash replace when the
relative slice doesn't contain any backslashes.
Also adds `benchmark/cases/unsafe-cache-miss-heavy/` which exercises the
cache-id path directly (a miss pass followed by a hit pass over 42 unique
requests, so `getCacheId` is the dominant cost) and unit tests for
`isRelativeRequest`.
Local results (Node 22, warm fs cache):
unsafe-cache (ON, 3x repeat): 11.5k → 14.5k ops/s (+25%)
unsafe-cache-miss-heavy: 2.2k → 2.8k ops/s (+27%)
realistic-midsize (warm cache): 4.2k → 4.6k ops/s (+9%)
realistic-midsize (cold cache): 42.5 → 46.6 ops/s (+10%)
One internal change: UnsafeCachePlugin cache keys are no longer valid JSON,
so test/yield.test.js was updated to split on the `\0` separator instead
of `JSON.parse`ing a key. The cache-key format has never been part of the
public API.
https://claude.ai/code/session_014HMqKsoba7AvAVojZWECzz
Extends the cache-hit work from PR #481 with additional hot-path wins that
don't change public behavior or semantics:
with a
\0separator instead ofJSON.stringifying a 6-key object perlookup. Paths, requests, queries and fragments produced by parseIdentifier
never contain raw
\0; context is still JSON-stringified when included,which escapes any
\0there./^\.\.?(?:\/|$)/regex used in UnsafeCachePlugin and getInnerRequest.lastIndexOfcalls (POSIX strings don't need to be fully re-scanned fora backslash that isn't there).
relative slice doesn't contain any backslashes.
Also adds
benchmark/cases/unsafe-cache-miss-heavy/which exercises thecache-id path directly (a miss pass followed by a hit pass over 42 unique
requests, so
getCacheIdis the dominant cost) and unit tests forisRelativeRequest.Local results (Node 22, warm fs cache):
unsafe-cache (ON, 3x repeat): 11.5k → 14.5k ops/s (+25%)
unsafe-cache-miss-heavy: 2.2k → 2.8k ops/s (+27%)
realistic-midsize (warm cache): 4.2k → 4.6k ops/s (+9%)
realistic-midsize (cold cache): 42.5 → 46.6 ops/s (+10%)
One internal change: UnsafeCachePlugin cache keys are no longer valid JSON,
so test/yield.test.js was updated to split on the
\0separator insteadof
JSON.parseing a key. The cache-key format has never been part of thepublic API.
https://claude.ai/code/session_014HMqKsoba7AvAVojZWECzz