← Back to Pull requests

perf(views): yield execution candidate reads #2039

Merged
mvschwarz merged 4 files (284 lines) on Oct 25, 2026 18:34 UTC
View on GitHub
mvschwarz mvschwarz commented on Oct 25, 2026 17:06 UTC
Author

Large execution views collect candidate rows in one synchronous SQLite call, making health checks and unrelated requests wait for seconds. Read WAL candidates through a request-owned readonly cursor that yields between slices, and serialize complete execution builds per projector. Transactions, memory and non-WAL databases retain synchronous main-handle reads.

SQL, bindings, row order and complete results are preserved. Candidates use one committed snapshot; later history reads can observe writes committed during yields. Native steps can still block, and queued execution requests can exceed the existing client deadline.

Validation: 138 focused tests, two independent transaction/cleanup adverses, and a matched source-built full-request case confirming complete-result parity apart from build identity and health-handler progress during the cursor read. This does not establish an overall request-time speedup.

🤖 Generated with Claude Code

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

<!-- coderabbit-ai-generated:v1 -->

Summary by CodeRabbit

Performance
Execution views can now yield between batches of database reads, helping keep the application responsive during larger reads.
Execution view updates are processed in order and continue after a failed update.
Reliability
Reads within an active transaction continue to use that transaction, preserving its data consistency.
Execution views show the same results across supported database configurations, aside from live disk-availability data.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 284 lines (+276 / -8) across 4 files Reviewer: openrig-review Review duration: 88m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.46) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 284 lines diff across 4 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.85 · 1 substantive comment(s)
0.85
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
87%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.338
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
3 items
coderabbitai[bot] coderabbitai[bot] commented on Oct 25, 2026 17:06 UTC
Bot

<!-- coderabbit-ai-generated:v1 -->

<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

<a href="https://app.coderabbit.ai/change-stack/mvschwarz/openrig/pull/2039?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>

<!-- review_stack_entry_end -->
<!-- recent_review_start -->

No actionable comments were generated in the recent review.

<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>

<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>

  • Source mode: Auto

  • Repository: Unavailable

  • Branch: Unavailable

  • File: No configuration file from this repository applied

  • Commit: Unavailable

  • Layers: defaults

  • Review profile: CHILL

  • Plan: Advanced

  • Run ID: e6d39f49-86dc-4bd6-be3c-3a80af769e2d
  • </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
    <dl>
    <dd>

    Reviewing files that changed from the base of the PR and between 00e2c8066d87200506ea7e3d768b5aae513c382b and 3973c4c0b7ee3d87094e585dbbc1d5f518e277b5.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</strong></summary>
    <dl>
    <dd>

    packages/daemon/src/domain/execution-candidate-reader.ts
    packages/daemon/src/domain/execution-view.ts
    packages/daemon/src/domain/view-projector.ts
    packages/daemon/test/execution-candidate-reader.test.ts

    </dd>
    </dl>
    </details>

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

    </dd>
    </dl>
    </details>

    <!-- recent_review_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Walkthrough</strong></summary>
    <dl>
    <dd>

    Execution-view candidate reads use a cooperative reader when the database is outside a transaction and uses WAL. Other cases retain synchronous reads on the main handle. The projector serializes execution-view builds outside transactions, while builds inside transactions run immediately.

    Changes: Execution-view reads

    |Layer / File(s)|Summary|
    |:---|:---|
    |Cooperative reader and eligibility <br> packages/daemon/src/domain/execution-candidate-reader.ts, packages/daemon/test/execution-candidate-reader.test.ts|Adds eligibility checks for WAL-backed database files and a readonly cursor that yields after 64 rows or 8 ms. Tests cover ordering, yielding, snapshots, errors, cleanup, and fallback cases.|
    |Execution-view candidate query <br> packages/daemon/src/domain/execution-view.ts|Uses cooperative reads for eligible databases. Runs the same candidate query synchronously on the main handle otherwise.|
    |Execution build ordering <br> packages/daemon/src/domain/view-projector.ts, packages/daemon/test/execution-candidate-reader.test.ts|Serializes execution-view builds outside transactions and continues the queue after a failed build. Tests also cover immediate builds inside transactions and memory/WAL document parity.|

    <!-- change_assessment_start -->
    <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong>

    Estimated code review effort: 3 (Moderate) | ~25 minutes

    <!-- change_assessment_commit:"3973c4c0b7ee3d87094e585dbbc1d5f518e277b5" -->
    Change: Refactor
    <!-- change_assessment_end -->

    Sequence Diagram(s)

    sequenceDiagram
      participant Caller
      participant ViewProjector
      participant buildExecutionView
      participant readRowsCooperatively
      participant ReadonlySQLiteConnection
      Caller->>ViewProjector: Request execution view
      ViewProjector->>buildExecutionView: Start build after prior build settles
      buildExecutionView->>readRowsCooperatively: Read candidates for eligible WAL database
      readRowsCooperatively->>ReadonlySQLiteConnection: Query rows in slices
      ReadonlySQLiteConnection-->>readRowsCooperatively: Return rows
      readRowsCooperatively-->>buildExecutionView: Return complete row set
      buildExecutionView-->>ViewProjector: Return projected view
      ViewProjector-->>Caller: Return execution view
    

    Possibly related PRs

  • mvschwarz/openrig#2031: Both changes affect the execution-view candidate query; this PR adds cooperative reads while preserving the query behavior changed there.
  • Suggested reviewers: rudycelekli

    </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>3973c</code></summary>
    <dl>
    <dd>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 3973c
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"3973c4c0b7ee3d87094e585dbbc1d5f518e277b5","coveredCommitId":"3973c4c0b7ee3d87094e585dbbc1d5f518e277b5","kind":"reviewed"} -->

    The reviewed change is mergeable after normal checks; no actionable risk remains established.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary>
    <dl>
    <dd>

    <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong>

    | Check name | Status | Explanation | Resolution |
    | :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- |
    | Docstring Coverage | !Warning | Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. |

    <details>
    <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary>
    <dl>
    <dd>

    | Check name | Status | Explanation |
    | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------- |
    | Description Check | !Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
    | Title check | !Passed | The title clearly and concisely describes the main change: yielding during execution candidate reads to reduce event-loop blocking. |
    | 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. |

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary><strong>Finishing Touches: 💡 1</strong></summary>
    <dl>
    <dd>

    <!-- finishing_touch_suggestion:docstrings -->
    <details open>
    <summary><strong>📝 Generate docstrings: 💡</strong></summary>
    <dl>
    <dd>

  • <!-- {"checkboxId":"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit to this branch

  • <!-- {"checkboxId":"7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create a new PR
  • </dd>
    </dl>
    </details>
    <details open>
    <summary><strong>🧪 Generate unit tests (beta)</strong></summary>
    <dl>
    <dd>

  • <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit to this branch

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    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.

    <details>
    <summary><strong>❤️ Share</strong></summary>
    <dl>
    <dd>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </dd>
    </dl>
    </details>

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    openrig-review openrig-review approved these changes on Oct 25, 2026 18:34 UTC
    Approved Reviewer

    Approved at 3973c4c0b7ee3d87094e585dbbc1d5f518e277b5, recording the completed independent source reviews and QA rather than claiming a new test run. I verified the four-file port and stable patch identity, prerequisite inclusion, clean current-main composition, and all eight required exact-head CI checks. The retained evidence covers complete-result parity and health-handler progress during cursor reads; it does not establish an overall request-time speedup or eliminate remaining synchronous work.

    — orch-lead@v-openrig-build

    Assignees
    mvschwarz mvschwarz
    Labels
    risk: low confidence: 87.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 46.2% (MEDIUM) · Higher = larger blast radius
    46.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 87.4% · Lower = rushed or shallow review
    87.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.8% · Safe to merge
    5.8%