You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: globalState write-through causes extension host freezes and OOM pause on large task histories #1541
The TaskHistoryStore correctly persists history items as individual JSON files on disk. However, ClineProvider also maintains a 5-second debounced write-through of the full getAll() array back into VS Code's globalState("taskHistory"). On any session with many or large tasks, this blob exceeds VS Code's recommended size, causing repeated extension host freezes and a "Pausing before OOM" self-protective pause.
Reproduction
Run a multi-child orchestrator session with 10+ tasks (or tasks with large completionResultSummary fields). Observe in the browser devtools console:
WARN [mainThreadStorage] large extension state detected
(ZooCodeOrganization.zoo-code, global: true): 2885 KB
Consider to use 'storageUri' or 'globalStorageUri' to store this data on disk instead.
This warning fires on every debounced write (every 5 s while a task is active), and on flushGlobalStateWriteThrough it fires synchronously. The extension host logs unresponsive / responsive pairs around each flush as it blocks serializing the blob over the RPC bridge. The webview shows "Pausing before OOM" when the blob approaches the size limit.
Every task update calls taskHistoryStore.atomicReadAndUpdate(), which calls the onWrite callback, which schedules the write-through. Each write serializes all history items (including full task, completionResultSummary, childIds, etc.) into a single VS Code key-value entry. A 13-task session with rich summaries produces a ~2.9 MB blob.
The write-through exists because some code paths still fall back to reading globalState("taskHistory") (e.g. ClineProvider.ts:1988, 2251, 2521) and webview hydration reads it from state.
Impact
Extension host becomes unresponsive for several seconds on every flush
Triggers the extension's own OOM guard ("Pausing before OOM") on large sessions
Grows unboundedly — each new task or updated completionResultSummary increases the blob permanently
Worst for orchestrator / multi-child sessions, which produce the largest histories
Proposed fix
Remove the globalState write-through entirely. Primary storage is already file-based. Update the remaining getGlobalState("taskHistory") fallback reads (ClineProvider.ts:1988, 2251, 2521) and webview hydration to read from TaskHistoryStore directly. Remove taskHistory from the GlobalState type.
A lighter intermediate step: write only a minimal index (id, ts, status, short task snippet) to globalState and always fetch full items from disk.
Prior art
Upstream Roo-Code tracked the same root cause in RooCodeInc/Roo-Code #3784. Zoo Code already migrated primary storage to files; this issue tracks the remaining write-through that still causes the problem.
Environment
Zoo Code 3.80.1
VS Code Remote (WSL2)
Observed globalState blob size: ~2885 KB (well above the ~1 MB threshold where VS Code warns)
A Chrome DevTools allocation sampling profile taken during an active session confirms setExtensionState as the dominant allocator in the renderer process.
Top allocators by sampled bytes (20 MB profiling window):
Sampled
Function
Source
5 786 KB
setExtensionState
workbench.desktop.main.js:1148
1 841 KB
n.onmessage
workbench.desktop.main.js:1124 (webview postMessage — see #630)
873 KB
get (native)
—
827 KB
LEn
workbench.desktop.main.js:5640
549 KB
deserializeRequestJSONArgs
workbench.desktop.main.js:5640
352 KB
deserializeReplyOKJSON
workbench.desktop.main.js:5640
144 KB
pushFrame
main.js (Zoo Code webview bundle)
setExtensionState is the #1 allocator at 5.8 MB per event — nearly 3× the next entry — sampled from a single profiling window. Its call tree:
setExtensionState
└─ store
└─ withPausedEmitters
└─ resume → fire → (anonymous) → fire
That is the exact VS Code globalState RPC path triggered by updateGlobalState("taskHistory", items) in scheduleGlobalStateWriteThrough. This is not correlation: the profiler captured the allocation at the point of the globalState.update() call.
For comparison, n.onmessage at 1.8 MB is the webview receiving the clineMessages array — a separate issue tracked in #630. The two issues are visible as distinct call sites in the same profile.
The deserializeRequestJSONArgs / deserializeReplyOKJSON entries (combined ~900 KB) are the RPC deserialization layer on the receiving end of the same blob.
Conclusion: removing scheduleGlobalStateWriteThrough and flushGlobalStateWriteThrough eliminates the 5.8 MB allocation entirely. The TaskHistoryStore file cache is already the source of truth; the write-through has no other consumers once the fallback reads in #1543 are removed.
Activity
edelauna commentedon Sep 6, 2026
Heap allocation profile — call-stack confirmation
A Chrome DevTools allocation sampling profile taken during an active session confirms
setExtensionStateas the dominant allocator in the renderer process.Top allocators by sampled bytes (20 MB profiling window):
setExtensionStateworkbench.desktop.main.js:1148n.onmessageworkbench.desktop.main.js:1124(webview postMessage — see #630)get(native)LEnworkbench.desktop.main.js:5640deserializeRequestJSONArgsworkbench.desktop.main.js:5640deserializeReplyOKJSONworkbench.desktop.main.js:5640pushFramemain.js(Zoo Code webview bundle)setExtensionStateis the #1 allocator at 5.8 MB per event — nearly 3× the next entry — sampled from a single profiling window. Its call tree:That is the exact VS Code globalState RPC path triggered by
updateGlobalState("taskHistory", items)inscheduleGlobalStateWriteThrough. This is not correlation: the profiler captured the allocation at the point of theglobalState.update()call.For comparison,
n.onmessageat 1.8 MB is the webview receiving theclineMessagesarray — a separate issue tracked in #630. The two issues are visible as distinct call sites in the same profile.The
deserializeRequestJSONArgs/deserializeReplyOKJSONentries (combined ~900 KB) are the RPC deserialization layer on the receiving end of the same blob.Conclusion: removing
scheduleGlobalStateWriteThroughandflushGlobalStateWriteThrougheliminates the 5.8 MB allocation entirely. TheTaskHistoryStorefile cache is already the source of truth; the write-through has no other consumers once the fallback reads in #1543 are removed.