Skip to content

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

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

Activity

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

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