Repository navigation
perf(vite): speed up inspect module list - #623
Open
webfansplz wants to merge 1 commit into
Open
webfansplz wants to merge 1 commit into
webfansplz wants to merge 1 commit into
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: |
webfansplz
force-pushed
the
perf/inspect-module-list
branch
from
October 23, 2026 04:03
287311d to
1d51c55
Compare
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
Two costs that grow with project size made the inspect collector compete with Vite for the main thread:
path.relativefor dependencies) on the hot path.get-modules-listqueries (one from the HMR update, one after the follow-up requests settle). Each query rebuilt the whole list in one synchronous run, so Vite couldn't serve any request in the meantime: about 100 ms per query at 15,000 modules.Changes
getChangeVersion(), which increases on every write that can change recorded modules (clearPendingLoadMetricsdoesn't count).getModulesListreturns the previous list until the version changes.Impact
Measured locally with a synthetic project (half of the modules under
node_modules, 20 plugins), median of 3 runs.With the panel open, per edit:
Without the panel, cold-start transform overhead at 15,000 modules goes from +33% to +21% because the id cache keeps hitting. Smaller projects already fit in the old cap and are unchanged.
The id cache uses about 9 MB when completely full (100,000 entries, about 97 bytes each, measured as heap with the cache filled minus heap after clearing it). It only grows that large in large projects or very long sessions.