Description
While OpenCode is waiting for a model response (spinner visible, no streaming yet), I'm seeing ~30% CPU on Linux. I did some digging and have a hypothesis about the cause.
Claude Sonnet tells me this:
- targetFps: 60 in rendererConfig() (packages/opencode/src/cli/cmd/tui/app.tsx)
The renderer appears to be configured at 60 FPS — double opentui's default of 30. This sets minTargetFrameTime = ~16ms.
- opentui-spinner may be driving the render loop via raw setInterval
The spinner component uses an 80ms interval (12.5 FPS). From what I can tell, opentui-spinner calls requestRender() on every tick via a raw setInterval rather than the Timeline system, scheduling a full frame every 80ms.
- Per-frame JS cost may not be gated on dirty state
opentui's JS-side render loop appears to walk the entire renderable tree and run Yoga layout on every frame. The native lib.render() already does cell diffing so the terminal write cost is cheap (just the spinner chars), but I couldn't find any path where renderSelf() is skipped for non-dirty renderables — the _dirty flag seems to be used for Yoga layout only.
The result seems to be ~12.5 full render frames/sec continuously while just waiting, with each frame doing a full Yoga + JS tree traversal regardless of what actually changed.
Environment
- OS: Arch Linux
- opencode: v1.4.1 from repos
Plugins
"@tarquinen/opencode-dcp@latest", "opencode-agent-memory@0.2.0", "oh-my-opencode-slim@0.9.5", "@slkiser/opencode-quota"
OpenCode version
1.4.1
Steps to reproduce
- Have a long-running request on a laptop
- Feel your lap heating up a bit
(I don't think there's anything particular to this, but I'll be happy to dig deeper)
Screenshot and/or share link
No response
Operating System
Arch Linux
Terminal
Alacritty
Description
While OpenCode is waiting for a model response (spinner visible, no streaming yet), I'm seeing ~30% CPU on Linux. I did some digging and have a hypothesis about the cause.
Claude Sonnet tells me this:
The renderer appears to be configured at 60 FPS — double opentui's default of 30. This sets minTargetFrameTime = ~16ms.
The spinner component uses an 80ms interval (12.5 FPS). From what I can tell, opentui-spinner calls requestRender() on every tick via a raw setInterval rather than the Timeline system, scheduling a full frame every 80ms.
opentui's JS-side render loop appears to walk the entire renderable tree and run Yoga layout on every frame. The native lib.render() already does cell diffing so the terminal write cost is cheap (just the spinner chars), but I couldn't find any path where renderSelf() is skipped for non-dirty renderables — the _dirty flag seems to be used for Yoga layout only.
The result seems to be ~12.5 full render frames/sec continuously while just waiting, with each frame doing a full Yoga + JS tree traversal regardless of what actually changed.
Environment
Plugins
"@tarquinen/opencode-dcp@latest", "opencode-agent-memory@0.2.0", "oh-my-opencode-slim@0.9.5", "@slkiser/opencode-quota"
OpenCode version
1.4.1
Steps to reproduce
(I don't think there's anything particular to this, but I'll be happy to dig deeper)
Screenshot and/or share link
No response
Operating System
Arch Linux
Terminal
Alacritty