Skip to content

Avoid retaining an unused OpenCode database worker - #26113

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-missing-opencode-worker
Oct 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-missing-opencode-worker

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​90 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​90
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14

ELI5

Orca no longer keeps an unused database worker running when OpenCode has never created its database.

What Changed

The binder checks once at startup and every minute. Previously, checking an absent database started a worker; each minute reset its two-minute idle expiry. An asynchronous file probe now returns the existing empty result before constructing the worker for ENOENT or ENOTDIR.

Why

A bundled production-worker measurement retained 22.7–27.2 MB of resident memory and took 33.6–37.2 ms to start just to return an empty result. This removes the allocation rather than changing idle timeouts or caching absence. Every call checks again, so installing OpenCode later is still detected. Other errors and deletion after the probe keep the existing worker handling.

Linked Issue

None; internal performance audit.

Visual Proof

N/A — background worker admission changes; displayed sessions and interaction behavior stay the same.

Testing

  • Automated tests added/updated.
  • 31 tests passed across admission, worker lifecycle, database reader and binder suites. The admission regressions fail against the previous implementation.
  • Full pnpm tc and changed-code quality passed; targeted formatting/lint passed.
  • macOS Node 24.20.0 measurement used the real production worker entry bundled with esbuild. RSS is process-level evidence, not a packaged Electron measurement. Linux/Windows run in CI.
  • Six admission cases cover missing file, missing parent directory, later database creation, EACCES, EIO and deletion after admission.

Review

The existing reader remains authoritative. No wire, SQLite query, provider routing, folder/worktree lookup or agent-status precedence changes. Each host checks its own OpenCode path; no client fallback or new cache.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • This PR is small and focused.
  • Before/after behavior, mechanism and approach explained.
  • N/A visual proof with reason.
  • Self-reviewed for correctness, security and performance.
  • Cross-platform and SSH/remote impact considered.
  • Typecheck, targeted tests and changed-code quality pass; full build/lint/suite left to CI.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7235aba-976f-4e46-b2d9-41e14fa6e8be
📥 Commits

Reviewing files that changed from the base of the PR and between 4077fb4 and 36705ec.

📒 Files selected for processing (2)
  • src/main/foreign-sqlite-readers/foreign-sqlite-reader-spawn.test.ts
  • src/main/foreign-sqlite-readers/foreign-sqlite-reader-spawn.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

readOpenCodeBinderSessions now probes dbPath before calling the shared reader. It returns no sessions for ENOENT and ENOTDIR; other probe failures continue to the shared reader. Tests cover these cases, dispatch after the database appears, and worker results when the database is removed during the call.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 36705

The change appears mergeable after normal checks; no outstanding issue is established.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: avoiding an unused OpenCode database worker.
Description check ✅ Passed The description explains the change, its purpose, testing, visual-proof status, and compatibility considerations. It marks the linked issue as none for an internal performance audit, which is consiste…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit a4854ac into main Oct 8, 2026
30 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