Skip to content

/file/content reads can retain filesystem search state #32237

@hereswilson

Description

@hereswilson

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:

  1. Create 12 temporary workspaces.
  2. Put 80 files in each workspace.
  3. Make each file about 128 KB.
  4. Start a local dev build of opencode with Bun 1.3.14.
  5. Repeatedly call /file/content for 100 steps across those workspaces.
  6. Sample the opencode-serve process RSS about once per second while the run is active.
  7. Compare the RSS before and after the run.

Screenshot and/or share link

N/A

Operating System

Windows 11 Home

Terminal

PowerShell / Windows Terminal

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions