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
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 runsdiff.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
snapshot.diffFull(from, to).Operating System
macOS (darwin-arm64) / Linux
Terminal
Ghostty / any