Skip to content

2.0 (linux): managed service main thread intermittently busy-loops in user space while idle (~100% of one core, no log/DB output) #51852

Open

Description

@vheins

Description

On Linux, the managed serve --service process intermittently burns a full core in user space while producing no observable output. Measured on a live process:

user ticks / 10 s : 1001     (100 ticks = 1 core-second -> ~100 % of one core)
sys  ticks / 10 s : 7
log lines / 10 s  : 0
DB writes / 10 s  : 0
RSS growth        : 853 MB -> 880 MB in 30 s

The load is in user space, which is why I am filing this separately from #36311, where the main thread was sampled spinning in the native write path (kernel-side). This may be a different variant.

(The 1001 user ticks measurement above was taken before I reduced host load. It is a historical observation, not the current steady state — see the intermittent samples below for present behaviour.)

Caveat: the spin is intermittent, not constant. Sampling the same process every 5 s over 60 s:

t= 5s  29%   t=35s  40%
t=10s  61%   t=40s   3%
t=15s  47%   t=45s   4%
t=20s  14%   t=50s   4%
t=25s   7%   t=55s   4%
t=30s   4%   t=60s  33%

I am not claiming a permanent wedge — I am reporting a recurring user-space spin that can push /api/info past the liveness window (~6 s in v2.0.18: requestTimeout: 2000 × 3 attempts), which then triggers kill + respawn (see #51216, #37795, #37239).

Correlated observations

Watcher churn in the same log:

Signal Count
watcher subscribe 22,555
watcher started 3,556
watcher stopped 1,467
watcher subscribe path=/ type=entries 258
watcher subscribe path=/home type=entries 247
watcher subscribe … .agents/skills 8,027

The service subscribes to / and /home as type=entries, plus a symlinked skills directory (~/.agents/skills → project .agents/skills → skills-src). Whether that causes the spin or is a co-symptom I did not isolate — the correlation is strong but I did not run a clean A/B.

Also: RSS grew ~27 MB / 30 s while idle.

Distinction from related reports

If maintainers consider this the same root cause as #42299, I am happy to fold this data into that issue instead.

Suggested investigation

  1. Profile the main thread during a spin (perf, or a Bun CPU profile) to identify the hot user-space path.
  2. Check whether the / and /home type=entries subscriptions plus symlink traversal are involved.
  3. Consider deriving liveness from something request work cannot block (as raised in desktop(win): background service SIGKILLed mid-turn when snapshot capture blocks /api/info for >6s -> ~60s restart loop, aborted turns #51216), so an intermittent spin does not get the server killed.

Workaround

OPENCODE_DISABLE_FILEWATCHER=true. After applying that plus the other load reductions here, the service stayed up 78 min with no restart (previously every 1–4 min).

Plugins

@tarquinen/opencode-dcp@latest, @vheins/opencode-9router, plus local plugins smart-voice-notify, opencode-discord-presence, opencode-vibeguard, opencode-asynchronous-agent.

OpenCode version

v2.0.18 (compiled binary ~/.opencode/bin/opencode, Bun 1.4.0)

Steps to reproduce

  1. Run v2.0.18 with the TUI on a loaded Linux host (load avg > 8 on 8 cores), several projects attached, one tree containing a symlinked skills directory.
  2. Sample the service main thread: awk '{print $14" "$15}' /proc/<pid>/stat over 10 s.
  3. Observe intermittent user-space CPU with no matching log or DB output.
  4. In the log, look for Background service is unresponsive → cli starting args=[serve --service] pairs.

Screenshot and/or share link

N/A

Operating System

Linux 6.12.38 (Debian/Kali), x86_64, 8 cores, 16 GB RAM, load average ~10–13, ~10 GB swap in use

Terminal

GNOME Terminal

Activity

  1. added
    needs:complianceThis means the issue will auto-close after 2 hours.
    and removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Sep 28, 2026
  2. github-actions commented on Sep 28, 2026

    @github-actions
    Contributor

    Thanks for updating the issue with the required description and reproduction details!

  3. mrvigneshvt commented on Oct 5, 2026

    @mrvigneshvt

    Matching case on the v2 CLI (@opencode/cli, managed opencode serve --service) — same chain, Linux laptop:

    1. Runs fine for a while.
    2. One core suddenly pins ~100% and the whole machine stalls — not just the app, the laptop becomes unusable.
    3. The service then terminates/restarts on its own. I never kill it. Sometimes the TUI shows "The server restarted while you were working"; sometimes nothing is printed at all.

    That fits the mechanism you describe: the spin outlasts the liveness window, /api/info stops answering, the supervisor treats the service as unresponsive and replaces it instead of reconnecting. Same shape as #52049 (45s event-stream watchdog), #51216 (~6s probe → SIGKILL → respawn) and the silent death in #50594.

    One trigger I'm checking on my side, from the follow-up in #50591: a stray .git above the working directory makes OpenCode treat a huge tree as the project and scan it (~26s per pass, twice per message). That's longer than the watchdog waits, so the service looks dead and gets restarted. Worth ruling out for this one too.

    Happy to add exact version, platform and logs.

  4. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed measurements, @vheins.

    Your report is on v2.0.18, and a relevant change has shipped since then. #55597 ("bound skill discovery and watches") went out in v2.1.0. It limits how deep skill directories are scanned and makes the skill directory watches skip dot-directories. That's the area your 8,027 .agents/skills subscribes point to. Could you:

    1. Upgrade to the latest release (v2.2.0 at the time of writing), turn the file watcher back on (unset OPENCODE_DISABLE_FILEWATCHER) and check whether the user-space spin and the Background service is unresponsive restarts still happen.
    2. If they do, capture a CPU profile or a perf sample of the service during a spike, so we can see which code is hot.
    3. Tell us which config, .opencode/.claude/.agents or skill directories you have at / or directly in /home. The path=/ and path=/home type=entries watches are parent-folder watches for config files that live there.

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.

    Related issues, ordered by likelihood:

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions