Repository navigation
perf(rolldown): keep loaded sessions cached and cap reader memory - #634
Merged
Merged
Conversation
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent-load cache pruning can dispose of a reader before its awaiting caller resumes, causing successful loads to return empty data.
1 open issue
What changed in this PR
This PR separates session metadata caching from Rolldown’s log-reader cache, reducing repeated log parsing when listing sessions and limiting cached log data.
Changes:
- Cache session metadata by file size and modification time without creating log readers.
- Add a 1 GiB log-byte budget, preserving the two most recent readers and pending reads.
- Add regression tests for session-list cache retention and budget-based eviction.
| File | Description |
|---|---|
packages/rolldown/src/node/rolldown/logs-manager.ts |
Adds metadata caching and uses it across listing and session loading. |
packages/rolldown/src/node/rolldown/events-reader.ts |
Adds byte-budget pruning, including pruning after reads complete. |
packages/rolldown/src/node/rolldown/__tests__/reader-cache.test.ts |
Tests cache retention and eviction protections. |
Review effort: Balanced
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.

Background
The Rolldown UI keeps parsed session logs in an in-memory reader cache (
RolldownEventsReader), capped at 32 readers by count only.Two problems came out of that:
list()created a reader for every session'smeta.json. With more than 32 sessions, opening the session list pushed the loadedlogs.jsonreaders (e.g. both sides of a compare view) out of the cache, so the next interaction re-read and re-parsed the full log, which can be hundreds of MB.Changes
logs-manager.ts: session metas are parsed by a newreadSessionMeta()and cached by file size + mtime, outside the reader cache.list()and theloadSession*helpers use it;deleteSessiondrops the cached entry. Event ids match what the events reader assigns.events-reader.ts: the reader cache is also bounded by total log bytes of fully read sessions (1 GiB). The two most recently used readers and readers with a pending read are never evicted. Pruning also runs after reads complete.reader-cache.test.tscovering both behaviors.