Repository navigation
[Improve] Reduce chat memory retained during long sessions - #2217
zoomote2[bot] wants to merge 8 commits into
Conversation
…y-optimization-0lkgswz0njjgl # Conflicts: # webview-ui/src/__tests__/App.spec.tsx # webview-ui/src/context/ExtensionStateContext.tsx # webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the
|
|
No new code issues found. See session Re-reviewed the new commit 2ff4aa6 ("Address webview memory optimization review feedback") on top of the previously reviewed 5ba6d60:
CI at this head: compile, codecov patch checks (including webview-patch), knip, translations, and VSIX build pass; remaining unit/visual/e2e jobs were still running at review time. Previously reviewed at 5ba6d60 — string interning ( Reviewed 31e260a |
Review statusThis PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging. Current step: Awaiting fresh human maintainer or CODEOWNER approval. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What changed
Why
State broadcasts repeatedly deserialize message and history strings. Sharing equal strings reduces retained allocations within a transcript and across successive snapshots. The cache limits bound its own retention; clearing a cache does not guarantee that other UI references release the same messages.
Heap measurements
Measured in real VS Code 1.100.0 under Xvfb using CDP forced GC on the Zoo Code webview renderer. Each workload loads a deterministic saved transcript of 602 UI messages, including 300 command/output pairs with 16.4–16.9 KiB outputs, then switches to a small task. A full-state refresh after hydration exercises sharing across broadcasts.
Three fresh measurement sessions per workload and variant produced 12 successful samples. The extension host, dependencies and styles are held constant; both webview builds use production minification without source maps. External downloads are blocked during the workload, and seed tasks use a local mock model.
Median loaded renderer heap:
Base webview modules:
97228c7ca9b032e5fe466e57e24fe72fbf405192. Candidate:b9a6ba03cb93c0f92f06cfb00c82ae7d488db7cb.These are historical measurements of the recorded revisions and have not been rerun for the review fixes. Repeated outputs benefit from cache interning; unchanged strings are also shared across snapshots after FIFO eviction, which helps the unique workload. The comparison does not isolate each mechanism’s contribution.
These replace the earlier standalone synthetic 8.6 MiB estimate. The new measurements exercise the real extension/webview path with generated saved-task data; they are not an organic user session and do not measure CPU overhead, image-rich messages, continuously streamed execution, extension-host heap, or process RSS.
Task-switch finding
All six candidate post-switch snapshots contain zero old output strings in the StringCache maps. Old output strings remain reachable elsewhere in both base and candidate. An inspected strong retaining path runs through React props and
onJumpToPreviousCheckpointcallback closure contexts into an old message array.Cache cleanup is confirmed, but complete task-memory release is not. Investigating that existing callback retention remains a follow-up; these snapshots do not establish indefinite growth. Chat behavior and appearance are unchanged, and no forced remounts are introduced.
Validation and artifacts
apps/vscode-e2e/src/heap/; raw snapshots, measurements and retaining-path evidence are gitignored underapps/vscode-e2e/heap-results/.