Skip to content

perf: cache-key and hot-path improvements atop issue #449 normalization#532

Merged
alexander-akait merged 2 commits intomainfrom
claude/perf-improvements-issue-449-19oam
Apr 17, 2026
Merged

perf: cache-key and hot-path improvements atop issue #449 normalization#532
alexander-akait merged 2 commits intomainfrom
claude/perf-improvements-issue-449-19oam

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

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.stringifying 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.parseing 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:

- 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
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 17, 2026

CLA Not Signed

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.58%. Comparing base (42b6620) to head (d5bf44d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #532      +/-   ##
==========================================
+ Coverage   96.52%   96.58%   +0.05%     
==========================================
  Files          50       50              
  Lines        2651     2665      +14     
  Branches      808      812       +4     
==========================================
+ Hits         2559     2574      +15     
+ Misses         77       76       -1     
  Partials       15       15              
Flag Coverage Δ
integration 96.58% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 17, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
🆕 1 new benchmark

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 unsafe-cache-miss-heavy: 1 miss pass + 1 hit pass N/A 4.3 ms N/A

Comparing claude/perf-improvements-issue-449-19oam (d5bf44d) with main (42b6620)

Open in CodSpeed

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 17, 2026

⚠️ No Changeset found

Latest commit: d5bf44d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@alexander-akait alexander-akait merged commit 3c4e574 into main Apr 17, 2026
33 of 34 checks passed
@alexander-akait alexander-akait deleted the claude/perf-improvements-issue-449-19oam branch April 17, 2026 15:35
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.

2 participants