Skip to content

perf(main): skip unchanged opencode binder polls via stat stamp and retire idle reader after 30s - #49671

Merged
nwparker merged 5 commits into
mainfrom
perf/skip-unchanged-opencode-binder-poll-and-retire-idle-reader
Nov 26, 2026
Merged

nwparker merged 5 commits into
mainfrom
perf/skip-unchanged-opencode-binder-poll-and-retire-idle-reader

Conversation

@nwparker

@nwparker nwparker commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Prevents the 60s OpenCode binder poll from permanently keeping an idle orca-foreign-sqlite-reader Node Worker isolate (~8 MiB dirty RAM) alive in Main when opencode.db has not changed:

  1. src/main/foreign-sqlite-readers/foreign-sqlite-reader-spawn.ts
    • Stat dbPath, ${dbPath}-wal, and ${dbPath}-journal (ino:size:mtimeMs) before waking the worker in readOpenCodeBinderSessions.
    • When a previous successful worker read returned [] for the exact (dbPath, cursor.ms, cursor.id) and file stamp, return [] immediately without waking the worker. Failed/timed-out reads are never cached.
  2. src/main/foreign-sqlite-readers/foreign-sqlite-reader-client.ts
    • Exposed readWithStatus / readOpenCodeBinderSessionsWithStatus so foreign-sqlite-reader-spawn.ts distinguishes verified empty reads from error fallbacks.
    • Lowered DEFAULT_IDLE_TEARDOWN_MS.openCodeBinderSessions from 120_000 → 30_000 (matching cursorProfile and openCodePromptFailure), since unchanged polls no longer need a warm worker bridging 60s intervals.

Performance

  • Retires orca-foreign-sqlite-reader after 30s of quiet and avoids waking it on unchanged 60s binder polls, reclaiming ~8 MiB of permanent dirty RAM in Main with zero negative user-facing tradeoffs.

Verification

  • pnpm check:changed --base=perf/idle-retire-environment-store-worker: 25/25 passed (including unit tests)
Files Added Deleted Net
Test 0 0 0 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61

…e writes

A commit landing in the same coarse mtime tick as the stat (WAL reset
rewriting in place at the same size, journal-mode page overwrites, FAT's
2s resolution, or ino === 0 platforms) could leave an identical
ino:size:mtimeMs stamp and skip the poll indefinitely. Trust a stamp
only after every file has been quiet for 3s, and include ctimeMs in the
token for extra discrimination.
@nwparker
nwparker changed the base branch from perf/idle-retire-environment-store-worker to main November 26, 2026 10:47
@nwparker
nwparker merged commit 90917d6 into main Nov 26, 2026
53 of 56 checks passed
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.

1 participant