anomalyco / anomalyco/opencode

snapshot.diffFull hangs process and exhausts memory on large generated text files

Open
#48,616 0 comments 0 reactions 1 assignee View on GitHub

@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
  1. In any repository, generate or modify a text file with 50,000+ lines (e.g. a mesh file or large log).
  2. Trigger any tool call or step that causes OpenCode to record a session snapshot.
  3. OpenCode triggers snapshot.diffFull(from, to).
  4. CPU spikes to 100%+ and the process freezes.
Operating System

macOS (darwin-arm64) / Linux

Terminal

Ghostty / any

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.