Repository navigation
perf(rolldown): speed up session logs - #628
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
Restoring cached sessions without module metrics hides metrics and plugin badges and produces zero module-based sizes, while later full reads do not refresh the affected client data.
1 open issue
What changed in this PR
This PR reduces Rolldown session reopening time and improves DevTools server responsiveness when processing large build logs.
Changes:
- Defers reader-index and module-metrics loading until a full read and avoids duplicate cache writes.
- Adds a binary reader-index cache with log validation and support for offsets beyond 4 GB.
- Adds time-sliced parsing and tests for codec integrity and summary-to-full restoration.
| File | Description |
|---|---|
packages/rolldown/src/node/rolldown/reader-index-codec.ts |
Adds binary index encoding and decoding with periodic yields. |
packages/rolldown/src/node/rolldown/log-cache.ts |
Integrates binary caches and lightweight summary restoration. |
packages/rolldown/src/node/rolldown/events-reader.ts |
Updates summary state handling and yields during parsing. |
packages/rolldown/src/node/rolldown/__tests__/reader-index-cache.test.ts |
Tests codec round trips, invalid data rejection, and cache restoration. |
Review effort: Balanced
webfansplz
marked this pull request as draft
November 4, 2026 06:27
Restoring a cached session summary skipped module-metrics-summary.json, so every module's build_metrics was undefined after reopening. The module list lost its metrics and plugin badges, and chunk sizes computed from transforms were zero; a later full read did not refresh the client's module list.
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
Opening a Rolldown session in DevTools reads the build's
logs.json, which gets very large for big projects. On a lobehub SPA build (~29k modules, 6.9M events, 4 GB log), reopening an already-parsed session still took almost a second and blocked the DevTools server in one ~700 ms chunk. This PR makes reopening near-instant and keeps the server responsive while large logs are read.Changes
session-summary.jsonand the module metrics the module list and chunk sizes rely on (41 MB); the index is loaded on the first full read (module or plugin details).reader-index.jsonis replaced byreader-index.bin(newreader-index-codec.ts). Encoding and decoding yield to the event loop regularly, offsets are stored as f64 so logs over 4 GB work, and a header with the log size and mtime rejects stale or truncated files. The cache version is bumped to 3, so existing caches are rebuilt.logs.jsonyields to the event loop about every 8 ms instead of once per 1 MB chunk.Impact
Measured locally on the lobehub log above (the build's log writer timed out on the last line, so the session is truncated by one event):
Cold open is ~5% slower in total because parsing now yields, in exchange for the server staying responsive. Its time is dominated by per-line
JSON.parse, GC, and building metrics; skipping largecontentstrings and buffer-based action detection were tried and were slower, so they aren't included.