Skip to content

Slow perceived response time due to excessive storage writes during streaming #11329

@taetaetae

Description

@taetaetae

Description

During streaming responses, OpenCode writes to storage (JSON files) on every reasoning-delta event. With fast streaming APIs, this results in hundreds of file writes per second.

Impact

  • High I/O overhead from frequent file system operations
  • Increased latency between receiving content and displaying it
  • Slower perceived response time compared to native CLI tools (e.g., kiro-cli)

Root Cause

In processor.ts, every delta triggers a storage write:

case "reasoning-delta":
  if (part.text) await Session.updatePart({ part, delta: value.text })

Session.updatePart calls Storage.write which writes to the file system on every call.

Proposed Solution

Throttle storage writes during streaming:

  • Accumulate content in memory
  • Only flush to storage every 50ms
  • Always flush on reasoning-end

Environment

  • OpenCode version: latest
  • Tested with Kiro API streaming responses

Metadata

Metadata

Assignees

Labels

perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions