Repository navigation
perf(vite): speed up inspect payload allocation - #621
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
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.
Summary
When modules are invalidated, the inspect store frees their space in the payload archive, and new records reuse those gaps. The free-space list was handled with full passes: every reclaim pushed the freed ranges and re-sorted and re-merged the whole list, and every allocation scanned the whole list for the best fit. The more edits a session went through, the more fragmented the archive became and the longer the list grew, so each edit got a little slower, with no upper bound. This work runs on the main thread right after an edit.
This PR keeps the cost of each reclaim and allocation independent of how fragmented the archive is. Allocation results are unchanged.
Changes
Impact
Measured locally with a synthetic project (5,000 modules × 200 lines, half under
node_modules, 20 plugins): 50 consecutive edits, each invalidating and re-requesting a different set of 200 modules. Median of 3 runs:After 50 edits the archive had about 4,400 free ranges. A CPU profile of the last edits showed about 22 ms per edit in
allocate,mergeFreeRanges, andreclaimbefore this change, compared with about 3.5 ms on the first edit. Short sessions and small projects don't build up enough free ranges to show a difference; the gain shows up in long dev sessions with many edits.