anomalyco / anomalyco/opencode
snapshot.diffFull hangs process and exhausts memory on large generated text files
@kitlangton is already working on this.
Since Sep 12, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When working in a repository with large generated text files (e.g. simulation meshes, large logs, or dataset dumps with 50,000+ lines or several megabytes) that are modified, OpenCode's snapshot service freezes the entire process.
Profiling shows single-threaded CPU usage pegged at 100%+ and memory expanding beyond 1.8GB before the TUI/event loop locks up completely.
The root cause is in snapshot.diffFull(): after tracking changes, it loads both the before and after files into memory as strings and runs diff.structuredPatch(). Running Myers diff algorithm in JavaScript on arrays of 50k–1,000k lines consumes O(ND) time/space, starving the event loop.
OpenCode version
1.18.30
Steps to reproduce
- In any repository, generate or modify a text file with 50,000+ lines (e.g. a mesh file or large log).
- Trigger any tool call or step that causes OpenCode to record a session snapshot.
- OpenCode triggers
snapshot.diffFull(from, to). - CPU spikes to 100%+ and the process freezes.
Operating System
macOS (darwin-arm64) / Linux
Terminal
Ghostty / any
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.