Description
This might be related to #20695.
Repeated /file/content reads appear to use more memory than expected. In a local reproducible run, plain file reads caused opencode-serve RSS (resident set size) to grow by about 523 MB.
The surprising part is that reading file contents seems to go through the cached location services, which can also set up filesystem search state. So a request that only reads one file may end up creating and keeping search data for the wider workspace.
I used a local workload harness to generate this result. It creates temporary workspaces, starts opencode serve, repeatedly calls /file/content, samples opencode-serve RSS, and records request latency. The harness is not part of opencode, so the useful reproduction details are the inputs below rather than the exact local command.
This issue is only about that specific file read behavior. It may be one piece of the broader memory discussion in #20695, but I do not know if it explains every memory problem there.
Observed locally:
- OpenCode: local dev build from
origin/dev at bf05e8a12
- Runtime: Bun
1.3.14
- OS: Windows 11 Home
- Workload: repeated
/file/content reads
- Config: 12 workspaces, 100 steps, 80 files per workspace, 128 KB files
opencode-serve RSS delta: +523.1 MB
- peak RSS:
993.0 MB
- harness finding:
memory.rss-growth
Plugins
N/A
OpenCode version
local dev build from origin/dev at bf05e8a12
Steps to reproduce
Using any script or harness that can call a local opencode serve process:
- Create 12 temporary workspaces.
- Put 80 files in each workspace.
- Make each file about 128 KB.
- Start a local dev build of opencode with Bun
1.3.14.
- Repeatedly call
/file/content for 100 steps across those workspaces.
- Sample the
opencode-serve process RSS about once per second while the run is active.
- Compare the RSS before and after the run.
Screenshot and/or share link
N/A
Operating System
Windows 11 Home
Terminal
PowerShell / Windows Terminal
Description
This might be related to #20695.
Repeated
/file/contentreads appear to use more memory than expected. In a local reproducible run, plain file reads causedopencode-serveRSS (resident set size) to grow by about523 MB.The surprising part is that reading file contents seems to go through the cached location services, which can also set up filesystem search state. So a request that only reads one file may end up creating and keeping search data for the wider workspace.
I used a local workload harness to generate this result. It creates temporary workspaces, starts
opencode serve, repeatedly calls/file/content, samplesopencode-serveRSS, and records request latency. The harness is not part of opencode, so the useful reproduction details are the inputs below rather than the exact local command.This issue is only about that specific file read behavior. It may be one piece of the broader memory discussion in #20695, but I do not know if it explains every memory problem there.
Observed locally:
origin/devatbf05e8a121.3.14/file/contentreadsopencode-serveRSS delta:+523.1 MB993.0 MBmemory.rss-growthPlugins
N/A
OpenCode version
local dev build from
origin/devatbf05e8a12Steps to reproduce
Using any script or harness that can call a local
opencode serveprocess:1.3.14./file/contentfor 100 steps across those workspaces.opencode-serveprocess RSS about once per second while the run is active.Screenshot and/or share link
N/A
Operating System
Windows 11 Home
Terminal
PowerShell / Windows Terminal