Skip to content

perf(vscode): shard parser cache storage to fix large-workspace lag#1681

Merged
riccardoferretti merged 3 commits into
mainfrom
fix/parser-cache-sharded-storage
Jul 12, 2026
Merged

perf(vscode): shard parser cache storage to fix large-workspace lag#1681
riccardoferretti merged 3 commits into
mainfrom
fix/parser-cache-sharded-storage

Conversation

@riccardoferretti

Copy link
Copy Markdown
Collaborator

The parser cache was persisted under a single workspaceState key, so every debounced sync serialized the entire cache (up to 10k entries, ~50MB) and shipped it over IPC to the main thread, freezing the UI on large workspaces during startup and while typing.

The cache now persists to 64 bucket files under the extension storageUri. A note maps to a stable bucket via a hash of its URI and only dirty buckets are rewritten, so persistence cost is proportional to the change, not the workspace size. The legacy workspaceState blob is migrated to the new layout on first activation and removed. Pending writes are flushed on shutdown, and clear() can no longer be undone by an in-flight sync.

Supersedes #1677.

The parser cache was persisted under a single workspaceState key, so
every debounced sync serialized the entire cache (up to 10k entries,
~50MB) and shipped it over IPC to the main thread, freezing the UI on
large workspaces during startup and while typing.

The cache now persists to 64 bucket files under the extension
storageUri. A note maps to a stable bucket via a hash of its URI and
only dirty buckets are rewritten, so persistence cost is proportional
to the change, not the workspace size. The legacy workspaceState blob
is migrated to the new layout on first activation and removed. Pending
writes are flushed on shutdown, and clear() can no longer be undone by
an in-flight sync.

Supersedes #1677.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
riccardoferretti and others added 2 commits July 11, 2026 15:48
Addresses review findings on the sharded cache storage:

- Persist migrated legacy entries before removing the workspaceState
  blob, so a crash during the debounce window cannot lose the cache
- Don't stamp the new CACHE_VERSION when clearing the outdated cache
  files fails, so stale-schema buckets are never loaded as current
- Remove the self-rescheduling retry in writeDirtyBuckets: a persistent
  write failure no longer retries (and warns) every second; dirty
  buckets are retried on the next sync or flush instead
- Make flush() sync directly rather than flushing the debounce, so
  buckets dirtied only by LRU eviction are persisted too
- Declare ICache.clear() as void | Promise<void> so async
  implementations are visible through the interface
- Reuse the exported writeFile in createMatcherAndDataStore and
  smart-folder storage instead of duplicating it; hoist the TextEncoder
- Clean up the temp storage dirs leaked by the cache spec
- Run prettier over the files touched by the branch

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@riccardoferretti riccardoferretti merged commit cd87d8d into main Jul 12, 2026
7 checks passed
@riccardoferretti riccardoferretti deleted the fix/parser-cache-sharded-storage branch July 12, 2026 18:23
@riccardoferretti

Copy link
Copy Markdown
Collaborator Author

@allcontributors add @ryanncode for code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant