Skip to content

"step-end" diff calculation blocks event loop indefinitely with 100% cpu #29762

Closed as not planned

Description

@asaf92

Description

Whenever a tool call generates a large diff, opencode freezes, stuck on 100% CPU, the RSS increases by around 1GB, and the bun event loop gets blocked (one reason why it's hard to debug/profile) making opencode unusable. The rest of the symptoms are just by-product of a blocked event loop so I won't describe them all (basically TUI is responsive but you can't really do anything).

The root cause is the summary diff calculation after "step-end".

This can be easily recreated by doing a tool call that creates a full-file diff in a file that's smaller than 2 MB.

Plugins

None

OpenCode version

1.15.11

Steps to reproduce

  1. Create an empty repo with the following generate.py script:
import json
import random
import string
from pathlib import Path

rows = []
for i in range(12500):
    rows.append(
        {
            "id": i,
            "key": f"item-{(i * 7919) % 12500:06d}",
            "payload": "".join(random.choice(string.ascii_letters) for _ in range(64)),
            "value": (i * 104729) % 1000003,
        }
    )
Path("foo.json").write_text(json.dumps(rows, indent=2, sort_keys=True) + "\n")

This script creates a file called foo.json which is under 2mb (otherwise diff is skipped)
2. Run the script to generate an initial foo.json
3. Start opencode and have your agent run the python script.
4. Once the tool call finishes, the agent will not continue it's turn. The TUI will not be blocked, but you can't stop the conversation with "escape", and the opencode process will be stuck on 100% CPU indefinitely.

Screenshot and/or share link

Image

Operating System

MacOS and Linux

Terminal

Doesn't matter

Activity

  1. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • Memory Megathread #20695: Memory Megathread — this is the central tracking issue for memory and CPU spike problems. The maintainers are actively collecting heap snapshots there to diagnose these issues. Your reproducible example could be very valuable — consider sharing it there as well and uploading a heap snapshot following the instructions in that issue.
  2. changed the title [-]Minutes of 100% CPU and 1gb+ memory spike during rebase merge conflict (with minimal example + root cause)[/-] [+]Freeze for minutes with 100% CPU and 1gb+ memory spike during rebase merge conflict (with minimal example + root cause)[/+] on May 28, 2026
  3. changed the title [-]Freeze for minutes with 100% CPU and 1gb+ memory spike during rebase merge conflict (with minimal example + root cause)[/-] [+]"step-end" diff calculation blocks event loop indefinitely with 100% cpu[/+] on May 29, 2026
  4. asaf92 commented on May 29, 2026

    @asaf92
    Author

    Also related:
    #20495
    #23362
    #29873

  5. github-actions commented on Jul 29, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions