Performance issue: session-child-cycle becomes extremely slow with many sessions #2326

Open
opened 2026-02-16 17:35:08 -05:00 by yindo · 6 comments
Owner

Originally created by @zenyr on GitHub (Oct 29, 2025).

Originally assigned to: @thdxr on GitHub.

Description

session-child-cycle (ctrl+right) and session-child-cycle-reverse (ctrl+left) become extremely slow in workspaces with many sessions (e.g., after subagents create child sessions). Response time exceeds 10 seconds, causing input lag and ignored commands.

Root cause: `Session.children()` in `packages/opencode/src/session/index.ts` performs O(N) scan of all sessions via `Storage.list()` and `Storage.read()` per cycle.

OpenCode version

0.15.23 (sessions persist across versions)

Steps to reproduce

  1. Create workspace with 500+ sessions (e.g., run complex tasks with subagents).
  2. Press ctrl+right or ctrl+left to cycle sessions.
  3. Observe delay in switching.

Screenshot and/or share link

Image

... no wonder 😅

Operating System

macOS (Darwin)

Terminal

No response

Originally created by @zenyr on GitHub (Oct 29, 2025). Originally assigned to: @thdxr on GitHub. ### Description session-child-cycle (ctrl+right) and session-child-cycle-reverse (ctrl+left) become extremely slow in workspaces with many sessions (e.g., after subagents create child sessions). Response time exceeds 10 seconds, causing input lag and ignored commands. Root cause: \`Session.children()\` in \`packages/opencode/src/session/index.ts\` performs O(N) scan of all sessions via \`Storage.list()\` and \`Storage.read()\` per cycle. ### OpenCode version 0.15.23 (sessions persist across versions) ### Steps to reproduce 1. Create workspace with 500+ sessions (e.g., run complex tasks with subagents). 2. Press ctrl+right or ctrl+left to cycle sessions. 3. Observe delay in switching. ### Screenshot and/or share link <img width="506" height="108" alt="Image" src="https://github.com/user-attachments/assets/4356a863-eb82-4e14-a93f-a4fbb1c0d588" /> > ... no wonder 😅 ### Operating System macOS (Darwin) ### Terminal _No response_
yindo added the perf label 2026-02-16 17:35:08 -05:00
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

good to know thx

@rekram1-node commented on GitHub (Oct 29, 2025): good to know thx
Author
Owner

@ry2009 commented on GitHub (Dec 9, 2025):

Should more then resolve the problem but open to comments or concerns:
https://github.com/ry2009/opencode/pull/4

@ry2009 commented on GitHub (Dec 9, 2025): Should more then resolve the problem but open to comments or concerns: https://github.com/ry2009/opencode/pull/4
Author
Owner

@zenyr commented on GitHub (Dec 10, 2025):

Guys please add input about your recent experience with this issue, since I myself have not suffered this issue these days.

  • Before: took >20s every time
  • After: takes <2s (not an exact science)

For the record

now my storage looks like this after extensive use of OC:

Image Image
  • No gigantic /session folder anymore! 👍 Huge W
  • No, the switch is not INSTANT fast yet. But it works within reasonable time nonetheless.

So... of course, this could be even better with more optimizations. But I consider this mostly solved.

@zenyr commented on GitHub (Dec 10, 2025): Guys please add input about your recent experience with this issue, since I myself have not suffered this issue these days. - Before: took >20s every time - After: takes <2s (not an exact science) # For the record now my storage looks like this after extensive use of OC: <img width="461" height="150" alt="Image" src="https://github.com/user-attachments/assets/a8eaf043-255e-4c78-8400-4cefbab279d3" /> <img width="605" height="192" alt="Image" src="https://github.com/user-attachments/assets/979a3a59-c8ed-4495-892f-41f356498911" /> - No gigantic `/session` folder anymore! 👍 _Huge W_ - No, the switch is not _INSTANT_ fast yet. But it works within reasonable time nonetheless. So... of course, this could be even better with more optimizations. But I consider this **mostly solved**.
Author
Owner

@ry2009 commented on GitHub (Dec 10, 2025):

@zenyr is this what you found naturally with the newest OpenCode version?

@ry2009 commented on GitHub (Dec 10, 2025): @zenyr is this what you found naturally with the newest OpenCode version?
Author
Owner

@rekram1-node commented on GitHub (Dec 10, 2025):

I did do a small optimization for subagent stuff in terms of perf that could be what fixed it

also we are improving the ux of subagent nav soon

@rekram1-node commented on GitHub (Dec 10, 2025): I did do a small optimization for subagent stuff in terms of perf that could be what fixed it also we are improving the ux of subagent nav soon
Author
Owner

@ry2009 commented on GitHub (Dec 10, 2025):

Should I close out my perf with extra caches fix then? @rekram1-node

@ry2009 commented on GitHub (Dec 10, 2025): Should I close out my perf with extra caches fix then? @rekram1-node
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2326