GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(opencode): Throttle storage writes during streaming to reduce I/O overhead by taetaetae · Pull Request #11328 · anomalyco/opencode

Conversation

@taetaetae

@taetaetae taetaetae commented Jan 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Problem

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, causing:

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

Fixes #11329

Analysis

I compared OpenCode with kiro-cli using the same Kiro API:

Aspect kiro-cli OpenCode
API endpoint Same (q.us-east-1.amazonaws.com) Same
TTFB 2-10s 2-10s
Delta handling Memory only File write per delta
Perceived speed Fast Slower

The bottleneck is in processor.ts:

case "reasoning-delta":
  if (part.text) await Session.updatePart({ part, delta: value.text })
  // This writes to file system on EVERY delta!

Session.updatePart calls Storage.write which does:

await Bun.write(target, JSON.stringify(content, null, 2))

Solution

Implement throttled storage writes for reasoning-delta events:

  • Accumulate content in memory (already happening via part.text +=)
  • Only flush to storage every 50ms (STREAMING_UPDATE_THROTTLE_MS)
  • Always flush on reasoning-end to ensure data persistence
  • No change to final content or persistence guarantees

Expected Impact

  • ~20x fewer file writes during streaming (assuming 1 delta/2.5ms average)
  • Reduced I/O overhead and CPU usage
  • Faster perceived response time
  • No change to final message content

Changes

  • Added STREAMING_UPDATE_THROTTLE_MS constant (50ms)
  • Added throttle state tracking (lastUpdateTime, pendingReasoningUpdates)
  • Modified reasoning-delta handler to throttle storage writes
  • Ensured reasoning-end always flushes pending updates

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cmdNiels and ItsWendell reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
taetaetae
perf(processor): Throttle storage writes during streaming to reduce I…
54eb3da
…/O overhead

## Problem

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, causing:

1. High I/O overhead from frequent file system operations
2. Increased latency between receiving content and displaying it
3. Slower perceived response time compared to native CLI tools

## Analysis

Comparing OpenCode with kiro-cli using the same Kiro API:
- Both receive streaming responses with similar TTFB (2-10s)
- kiro-cli renders directly to terminal (memory only)
- OpenCode writes every delta to storage via Session.updatePart()

The bottleneck is in processor.ts:
```typescript
case "reasoning-delta":
  if (part.text) await Session.updatePart({ part, delta: value.text })
  // This writes to file system on EVERY delta!
```

## Solution

Implement throttled storage writes for reasoning-delta events:
- Accumulate content in memory (already happening via part.text +=)
- Only flush to storage every 50ms (STREAMING_UPDATE_THROTTLE_MS)
- Always flush on reasoning-end to ensure data persistence
- No change to final content or persistence guarantees

## Expected Impact

- ~20x fewer file writes during streaming
- Reduced I/O overhead
- Faster perceived response time
- No change to final message content
@github-actions github-actions Bot added the needs:title label Jan 30, 2026
@github-actions

github-actions Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title perf(processor): Throttle storage writes during streaming to reduce I/O overhead doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@taetaetae taetaetae changed the title perf(processor): Throttle storage writes during streaming to reduce I/O overhead fix(opencode): Throttle storage writes during streaming to reduce I/O overhead Jan 30, 2026
@github-actions github-actions Bot added needs:issue and removed needs:title labels Jan 30, 2026
@github-actions

github-actions Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:issue label Jan 30, 2026
@taetaetae taetaetae mentioned this pull request Jan 30, 2026
Slow perceived response time due to excessive storage writes during streaming #11329
Closed
@rekram1-node

rekram1-node commented Jan 30, 2026

Copy link
Copy Markdown
Member

we are moving to sqlite

cmdNiels reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@taetaetae
Merge branch 'dev' into perf/throttle-streaming-updates
cb59edd
vbuccigrossi pushed a commit to vbuccigrossi/opencode that referenced this pull request Mar 7, 2026
EBrown @claude
feat: port remaining Tier 1+2 upstream fixes and features
63e7373
Tier 1 bug fixes:
- Fix O(n²) bash output concatenation with StreamingOutput class (anomalyco#9693)
- Fix memory leaks in Bus.once, Format, Plugin, ShareNext, Bootstrap (anomalyco#13514)
- Fix FileTime race condition using actual file mtime instead of JS clock
- Free memory on compaction prune: clear output/attachments/metadata (anomalyco#7049)
- Throttle reasoning-delta storage writes to 50ms intervals (anomalyco#11328)
- Handle SIGHUP/SIGTERM to prevent orphaned processes (anomalyco#12718)
- Add process.once("close") handler for bash tool reliability

Tier 2 features:
- Support 1M context window for Anthropic models via beta header (anomalyco#14375)
- Input-only token counting for compaction with limit.input models
- MCP lazy loading: on-demand tool discovery via mcp_search tool (anomalyco#8771)
- MCP servers listed in system prompt when lazy mode enabled
- StreamingOutput: output_filter regex for build diagnostics
- LSP server cleanup callback for temp directory removal
- Extract formatSize utility from uninstall to shared util/format
- GitHub CI: fix Bus subscription leak in session event handler

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions github-actions Bot mentioned this pull request Mar 10, 2026
Add SQLite storage layer with FTS5 for memory-efficient data persistence #16913
Closed
4 of 6 tasks
@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Apr 4, 2026
@AidenGeunGeun AidenGeunGeun mentioned this pull request May 3, 2026
Electron desktop stalls during bursts of storage writes #25629
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Slow perceived response time due to excessive storage writes during streaming

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@taetaetae @rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.