Mitigate memory spikes from event backlog and shell output#24525
Mitigate memory spikes from event backlog and shell output#24525zjy-dev wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Found a potentially related PR: #16346: fix(opencode): unbounded memory growth during active usage This PR also addresses unbounded memory growth issues, which is the core problem that PR #24525 is solving. While the older PR may have tackled different aspects of memory management, it's worth checking if #16346 already addresses some of the same memory issues or if there's overlap in the solutions (event backlogs, shell output, or metadata updates). |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
Problem
We have reports of OpenCode processes growing to several GB of RSS and getting OOM-killed during longer sessions.
The main amplification paths identified here were:
Changes
Event backlog protection
AsyncQueuesupport256PubSub.unboundedtoPubSub.sliding(1024)Tool metadata reduction
ctx.metadata()updates in the shared tool execution pathShell output memory reduction
Validation
AsyncQueuebehavior with runtime scriptsPubSub.slidingsemantics with a runtime script ([2,3,4]retained from publishing1,2,3,4into capacity3)Notes