Skip to content

improve(sqlite): transfer privately owned worker command buffers - #156200

Draft
vincentkoc wants to merge 2 commits into
mainfrom
perf/async-sqlite-20260922
Draft

vincentkoc wants to merge 2 commits into
mainfrom
perf/async-sqlite-20260922

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Closes #156198

Draft: performance remains unqualified. The earlier approximately 12% slower candidate median is unresolved; no speedup or merge clearance is claimed.

Change

The SQLite broker already snapshots commands before queueing them. This candidate transfers its privately owned serialized command bytes to the worker, avoiding another structured-clone copy for eligible buffers. It reuses ownedWorkerBytes, which already owns worker reply transfers, for inline commands and independently serialized continuation frames.

Caller buffers stay attached. The complete frame producer snapshot, operation-admission port, opening-input custody, queue credits, per-slot admission, FIFO and existing retirement owner remain intact. Initial-dispatch error classification is unchanged. The continuation send-then-throw test is injected fault/custody proof after command admission; it does not establish that native Node throws after enqueue.

Production: +10/-5, net +5, in one transport owner. Tests/support: +252/-82, net +170, covering private transfer, full/sliced/pooled caller buffers, snapshot mutation, 40/72 MiB frames, queued followers, joined exit, successful close/reopen, durable readback and no replay. Observer tests capture command facts before transfer while preserving request/worker correlation.

Validation

  • Published candidate: e3f591d1333d8eb052fdca551f2f16cd7dfc2dfe; tree: 9cda5b4e5b175f10707650aba98f9a79f9b75123. Frozen main baseline: bfcec878635d9725d15f5f33af478da1f511d7f4. The normal signed merge preserves the original b8607480 branch ancestry.
  • Native Testbox commands ran on Linux x64 / Node 24.19.0 / pnpm 12.5.1, with exact selected-source and frozen dependency checks. The lease-provisioning workflow ran from 1b919d5e; the proof below comes from the native command results, not candidate CI on that workflow. All reported completed children were joined.
  • The initial eight-file run passed 137 tests, with one declared Darwin/SetFile-only skip. After narrowing the candidate, the complete SQLite input file passed 9/9, including the continuation retirement case. The other seven suites' earlier transfer/observer coverage is reused; this is not a fresh eight-file run of the final tree. Subsequent edits only renamed local test bindings, with disposal and behavior preserved.
  • The nine-case input file took 10.067s; its command took 42.725s, including runner preparation. Initial infra/config/Gateway group commands took 135.640s / 47.293s / 48.759s. These are single-pass costs, not baseline/candidate timing comparisons.
  • Targeted formatting and nine-file oxlint pass. The canonical owning state-logging test-type graph passes after the substantive reduction (37.774s). Production core types and the touched Gateway/config/plugin graphs passed in the preceding static run; the remaining planned guards subsequently passed on the narrowed source.
  • Aggregate check:changed remains failed: frozen baseline and candidate both count 484 OPENCLAW_* names against budget 483. The changed production file does not change that set; the budget was not raised. The broad test-type batch also reached its 900s command cap in ui-pages, after 14 named graphs passed. No full aggregate type success is claimed.
  • Independent source review reported no P0 findings or suspected credentials. Final disposal-binding-only edits received direct delta review. Runtime proof is Node-only. New published-head CI and Claw review remain separate from these source-tree receipts.

Performance hold and remaining work

This cycle's single capability attempt exited 78 at the observed namespace-root cgroup assertion, before quiet intervals or samples. This does not establish that pressure counters were missing. No baseline comparison build, baseline suite-cost measurement or benchmark sample ran, and no performance admission retry occurred.

Earlier attempts remain relevant: one Blacksmith image lacked pressure files; a separate AWS attempt failed its second quiet interval at approximately 9.96% I/O pressure, above the declared 1% ceiling. Both produced zero samples. Earlier noisy 72 MiB measurements had a candidate median approximately 12% slower, still unresolved.

The Claw cleanup-contract concern is reconciled with the frozen main owner: failed continuation retirement joins native exit, rejects the admitted operation/queued follower appropriately, and permits successful close and recovery. The performance/test-cost rank-up remains open: obtain the fixed three alternating 72 MiB pairs and three 128-write pairs on a positively admitted host, with durable-state/FIFO/caller-ownership/no-replay assertions and comparable baseline test costs. Keep this PR draft until that evidence and exact-head CI/review justify adoption. The frozen-main environment-budget failure is a separate named follow-up.

Transfer private command snapshots and staged frames while preserving caller buffers and opening-input custody. Treat a throwing first send as an uncertain native outcome, join worker exit, and preserve no-replay settlement.
@vincentkoc vincentkoc self-assigned this Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check could not safely complete for this revision.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: No contributor action is requested. Maintainers should inspect the linked workflow run.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 6:08 AM ET / 10:08 UTC (Revision 5).

ClawSweeper review

What this changes

The branch transfers broker-owned SQLite command buffers and staged frames to worker threads while preserving caller buffers and retiring workers after uncertain sends.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open. Current main still copies SQLite command bytes when posting them to workers, and the paired issue remains open. The branch offers distinct work, but its cleanup expectation conflicts with a merged lifecycle change and its performance benefit remains unqualified.

Priority: P2
Reviewed head: b860748026d176a469636656045e4c543d4534f7

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The transport change has meaningful worker-boundary coverage, while current-main integration and qualified performance evidence remain unresolved.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its tests exercise the real SQLite worker transport and observable buffer detachment, but the reported runs predate current-main reconciliation and do not establish a speedup; no stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its tests exercise the real SQLite worker transport and observable buffer detachment, but the reported runs predate current-main reconciliation and do not establish a speedup; no stored-data contract changes.
Evidence reviewed 8 items Introduced transport change: The pinned merge-base-to-head diff adds owned-buffer transfer for execute commands and continuation frames.
Current main lacks the transfer: Current main posts the command and continuation request without transferring their input buffers, so the branch's central change remains distinct.
Introduced stale cleanup assertion: The changed staged-transfer test expects store.close() to reject after worker retirement; a second new first-send case makes the same expectation at line 340.
Findings 1 actionable finding [P2] Preserve clean close after completed worker retirement
Security None None.

How this fits together

The SQLite worker broker receives serialized database commands from Gateway and plugin callers, queues them, and sends them to worker threads. It returns database results and settles worker cleanup before releasing callers.

flowchart LR
A[Database caller] --> B[Broker command snapshot]
B --> C{Buffer privately owned?}
C -->|Yes| D[Reuse buffer]
C -->|No| E[Make private copy]
D --> F[Transfer to SQLite worker]
E --> F
F --> G[Database result]
G --> H[Cleanup and settlement]
Loading

Before merge

  • Preserve clean close after completed worker retirement (P2) - The changed staged-failure test expects store.close() to reject, while current main changed that same case to resolve after cleanup. Reconcile this assertion and verify the new first-send case against the integrated lifecycle, preserving outcome-unknown and no replay for the dispatched operation.
  • Resolve merge risk (P1) - The branch conflicts with current main's worker cleanup behavior; integration must preserve clean close after completed retirement without hiding genuine cleanup failures.
  • Resolve merge risk (P1) - No qualified baseline-to-candidate timing comparison has resolved the earlier roughly 12% slower large-command median, so merging this optimization could worsen SQLite command latency.
  • Complete next step (P2) - Reconcile the branch with current main, correct the staged-failure close expectation, verify both failed-transfer cases on the integrated head, and publish qualified performance and test-cost results before merge.

Findings

  • [P2] Preserve clean close after completed worker retirement — src/infra/sqlite-worker-input.test.ts:300
Agent review details

Security

None.

PR surface

Source +12, Tests +113. Total +125 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 23 11 +12
Tests 5 165 52 +113
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 188 63 +125

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #156198
Summary: This PR is the candidate implementation for the open command-copying issue; the merged archive-cleanup PR establishes a separate lifecycle contract that integration must preserve.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Reconcile and measure (recommended)
    Preserve current-main cleanup semantics, verify the integrated worker path, and complete the controlled performance comparison before making the PR ready.
  2. Pause the optimization
    Keep the copying path if qualified measurements confirm a slowdown or the lifecycle integration cannot preserve reliable settlement.

Technical review

Best possible solution:

Integrate private-buffer transfer into the current broker lifecycle, preserve clean retirement and no-replay settlement, and land it only after controlled large- and small-command comparisons establish a useful result.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction: source shows the extra worker-message copy, and the branch tests buffer custody, but end-to-end speed benefit has not been established.

Is this the best way to solve the issue?

Unclear. The existing owned-buffer helper fits this transport boundary, but the branch must retain current cleanup behavior and demonstrate a performance benefit.

Full review comments:

  • [P2] Preserve clean close after completed worker retirement — src/infra/sqlite-worker-input.test.ts:300
    The changed staged-failure test expects store.close() to reject, while current main changed that same case to resolve after cleanup. Reconcile this assertion and verify the new first-send case against the integrated lifecycle, preserving outcome-unknown and no replay for the dispatched operation.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 340cb1c8402a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded SQLite transport improvement whose benefit and integration safety still need qualification.
  • merge-risk: 🚨 availability: The changed uncertain-send path retires a worker and affects queued work, while the branch has not reconciled current cleanup behavior.
  • merge-risk: 🚨 other: The intended performance improvement could instead add latency; the available controlled comparisons yielded no benchmark samples.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its tests exercise the real SQLite worker transport and observable buffer detachment, but the reported runs predate current-main reconciliation and do not establish a speedup; no stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Reconcile the failed-transfer close cases with current main and verify retirement on the integrated head.
  • Publish qualified large- and small-command comparisons and measured wall times for materially changed test files.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-23T05:11:46.324Z sha b860748 :: blocked before merge. :: none
  • reviewed 2026-09-24T08:09:06.472Z sha b860748 :: blocked before merge. :: [P2] Preserve successful close after completed worker retirement
  • reviewed 2026-09-24T08:53:44.801Z sha b860748 :: blocked before merge. :: [P2] Preserve successful close after completed worker retirement
  • reviewed 2026-09-24T09:46:31.542Z sha b860748 :: blocked before merge. :: [P2] Preserve successful close after completed worker retirement

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026

This branch has not been deployed

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

Labels

merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: reduce SQLite worker command copying

1 participant