Skip to content

fix(opencode): speed up long session forks - #41701

Open
evan-choi wants to merge 9 commits into
anomalyco:devfrom
evan-choi:fast-session-fork
Open

fix(opencode): speed up long session forks#41701
evan-choi wants to merge 9 commits into
anomalyco:devfrom
evan-choi:fast-session-fork

Conversation

@evan-choi

@evan-choi evan-choi commented Aug 11, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #41698

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A synthetic 986-message session now forks in 625 ms instead of 4.3 s6.8× faster.

Forks publish and project cloned events in 3,000-event batches, while source messages are read in 1,000-message pages. The SQLite schema and single-event publishing path are unchanged.

Benchmark

Environment

  • Host: MacBookPro18,1, Apple M1 Pro, 32 GiB, arm64
  • Software: macOS 26.5.2, Bun 1.3.14
  • Database: Fresh SQLite file per run (MAX_VARIABLE_NUMBER=500000)
  • Method: Same worktree and dependencies, 5 runs per revision, session.fork(...) only

Fixture

Messages Parts Summary Durable events Data
986 5,657 (493 step-finish) 25 MiB 6,644 Generated by the benchmark

Raw results

Run Baseline 5635afc949 (ms) PR head 5960d14fd1 (ms)
1 4,274 656
2 4,255 665
3 4,246 613
4 4,081 619
5 4,281 625
Median 4,255 625

Improvement

Median Reduction Speedup
4,255 ms → 625 ms 85.3% 6.8×

How did you verify your code works?

  • packages/core: typecheck; 1,084 tests passed
  • packages/opencode: typecheck; 3,268 tests passed, 22 skipped, 1 todo
  • Fork benchmark: 5 runs per revision
  • Pre-push workspace typecheck: 30/30 tasks passed

Screenshots / recordings

N/A — this is a non-UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Forking long sessions takes several seconds

1 participant