Repository navigation
Stop re-parsing bun lock entries for every patch in scan (#580) - #1051
Queued
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Queued
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
…write rewrite_bun_lock ran is_bundled_entry, a full serde_json parse of each entry's meta object, before the cheap spec comparison, once per (patch, entry) pair. On the bench fixture (about 3,000 entries x 127 patches) that is roughly 380k JSON parses per scan, which doubled bun/hosted and bun/rescan after #472 (144 -> 302 ms). Decode each entry's spec once per lock, compare it first, and compute the bundled flag lazily (cached per entry) only for entries whose spec matches a patch. Bundled entries are still skipped, warned about and kept out of VEX. Refs #578, #580 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
classify_rewritable and bundled_matches now run classify first and only parse the meta of entries that match the target. is_bundled_entry skips the JSON parse when the meta never spells "bundled" and holds no backslash (so an escaped key still takes the parse). Malformed meta that mentions "bundled" still fails closed. Refs #578, #580 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 8, 2026 11:22
Collaborator
Author
|
[agent] Merged main, CI green; ready for review. Generated by Claude Code |
Collaborator
Author
|
Ready for review (burn-down agent).
Nothing specific flagged for the reviewer beyond the PR description. Generated by Claude Code |
Tanmay Singla (Tanmay182003)
approved these changes
Oct 8, 2026
Mikola Lysenko (mikolalysenko)
added this pull request to the merge queue
Oct 8, 2026
Any commits made after this event will not be merged.
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 8, 2026
Mikola Lysenko (mikolalysenko)
added this pull request to the merge queue
Oct 8, 2026
Any commits made after this event will not be merged.
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 8, 2026
Mikola Lysenko (mikolalysenko)
added this pull request to the merge queue
Oct 8, 2026
Any commits made after this event will not be merged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the bun scan slowdown reported on #580. The hosted and vendored bun paths were re-parsing each lock entry's JSON on every (patch, entry) pair.
Why
The maintainer asked on #580 whether the bun regression came from a bug fix or from wasted work. It is mostly wasted work that came in with a real fix. The slowdown was bisected to #472 (1169ae6), which correctly stopped rewriting Bun
{"bundled": true}entries. The fix is legitimate, but it ranis_bundled_entry, a fullserde_jsonparse of the entry's meta object, before the cheap spec comparison. That parse ran once per (patch, entry) pair: about 3,000 entries × 127 patches ≈ 380k JSON parses per scan. bun/hosted went from 144 to 302 ms; the request count was unchanged, so the cost is all CPU.Change
rewrite_bun_lock(redirect/mod.rs): decode each entry's spec once per lock and compare it first. The bundled flag is computed lazily, and cached per entry, only for entries whose spec matches a patch.classify_rewritable/bundled_matches(vendor/bun_lock.rs): classify first, and parse meta only for entries that match.is_bundled_entry(bun_lock_text.rs): fast path that skips the JSON parse when the meta never spellsbundledand contains no backslash, so an escaped key still goes through the parse. Malformed meta that mentionsbundledstill fails closed.The behavior from #472 is kept: bundled entries are still skipped, warned about and left out of VEX.
Results
rewrite_bun_lockmicrobench on the bench fixture: 177.2 ms → 4.4 ms.Refs #578, #580. The bench tracking issue stays open.
🤖 Generated with Claude Code
Note
Low Risk
Behavior-preserving performance refactor with regression tests; bundled skip/warn/VEX rules unchanged from #472.
Overview
Fixes #580 bun scan slowdown by avoiding redundant work on every patch×lock-entry pair while keeping #472 bundled-entry skip semantics.
rewrite_bun_locknow decodes each entry’s spec once per lock and caches whether an entry is bundled only after a cheap spec match, instead of JSON-parsing meta on every patch loop. Vendoring (classify_rewritable,bundled_matches) uses the same order: classify first, thenis_bundled_entry.is_bundled_entryadds a substring fast path that skipsserde_jsonwhen the meta cannot contain abundledkey (still parsing when a backslash might hide an escaped key).New tests lock in that bundled warnings/VEX skipping apply only to matching specs, and that the fast path matches the full parse.
Reviewed by Cursor Bugbot for commit fe5a42a. Configure here.
Generated by Claude Code