Repository navigation
perf(state): remove SQLite reply completion envelopes - #184101
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8345056b1a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8345056 to
a6fea44
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR inlines SQLite reply decoding into its existing caller and removes temporary completion and continuation envelopes. Example: A SQLite worker returns the scalar result 42.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR makes a focused allocation reduction, and inspection found no introduced production defect. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe SQLite broker receives serialized worker replies, assembles bounded transfers, publishes receipts, and settles the waiting operation through its existing admission owner. flowchart LR
A[State operation] --> B[SQLite broker]
B --> C[Database worker]
C --> D[Reply decoder]
D -->|More frames| C
D --> E[Receipt and admission settlement]
E --> F[Waiting caller]
Technical reviewBest possible solution: Keep direct decoded-value assignment in the existing reply owner while preserving serialization, framing, receipts, and settlement. Do we have a high-confidence way to reproduce the issue? Current main constructs a completion object for successful decoded replies; source confirms the allocation path, and no target code was executed during this read-only review. Is this the best way to solve the issue? Inlining the single-use decoder removes the unnecessary representation at its existing owner without adding state, caches, or a competing path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5bc90d07df85. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -16, Tests +23, Other +140. Total +147 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 10:52 PM ET / October 26, 2026, 02:52 UTC. |
* perf(state): remove SQLite reply completion envelopes * test(state): allow direct decoded reply handoff
What Problem This Solves
Every successful SQLite worker reply allocates a completion envelope solely to pass its decoded value back to the reply owner. This adds avoidable main-thread allocation during frequent state reads and writes.
User Impact
A small allocation reduction with no user-visible behavior change. Result values/types, bounded framing, native receipts, cleanup failures, and current-authority settlement retain their existing behavior. No configuration, schema, migration, or stored-data changes.
Why This Change Was Made
Inline the decoder into its sole caller's existing diagnostic scope. Completed replies assign their decoded value directly; incomplete transfers return their existing continuation request. Delete both temporary envelope variants and the single-use decoder helper. V8 serialization/deserialization stays: it preserves result types and participates in transport-size and uncertain-write contracts.
Runtime production delta: −16 LOC (+75/−91, mostly moving the decoder into its caller). The standalone measurement script adds 140 tooling lines; the regression adds 23 test lines. No cache or alternate fast path.
Evidence
The regression fails on base
d4ae3a73118767a3f9bf80625a91733d19055393: the diagnostic callback hands off an additional{type: "complete", value: undefined}wrapper. With the change, completed replies settle the exact decoded values (including Buffer and bigint) without that wrapper. Completion wrappers handed off: 1 → 0 per reply. The regression permits either no callback result or direct decoded-value identity; it does not fix the diagnostic return shape or claim to detect arbitrary discarded allocations. The separate benchmark measures allocated bytes.Owner benchmark:
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/sqlite-worker-reply-measure.ts. ActualreceiveSqliteWorkerReply, synthetic scalar/session-entry/64-row-page results, prepared jobs and serialized inputs outside the loop. Node v26.12.1, macOS arm64, A/B then B/A. Each arm has five 5,000-reply untraced timing passes and one separate 5,000-reply allocation pass including collected objects (512-byte sampling). Table uses mean of each arm's median CPU and mean sampled allocation; 50,000 timing replies plus 10,000 allocation replies per revision per shape.This is a small allocation win, not a demonstrated CPU or whole-Gateway latency improvement. CPU pair deltas have mixed signs; page cost remains dominated by required deserialization. Host one-minute load by arm: base A 25.96→24.84; candidate B 27.54→29.66; candidate B 29.66→29.66; base A 29.45→33.74. End-of-page sampled-pass RSS/heap MiB: base 334.5/75.8 and 336.9/75.9; candidate 336.1/75.6 and 318.5/75.3. Memory snapshots are context, not retained-heap claims. No 10-minute Gateway stress or A/A campaign was run for this envelope deletion; there is no claim of Gateway p99, GC-rate, or throughput improvement.
Focused proof: 46 tests passed across
sqlite-worker-broker-reply.test.ts,sqlite-worker-broker-reply.cleanup.test.ts,sqlite-worker-input.test.ts, andsqlite-worker-store.test.tswith--maxWorkers=1. This includes real worker round trips, 72 MiB input framing, receipt ordering, cleanup/outcome uncertainty, and post-commit serialization failure. Combined wall time 83.64 s (74.30 s Vitest, including worker fixture compilation); the changed reply test's cases run in milliseconds. No Testbox lease used; broad gates belong to PR CI.Export-name collision guard and both closure test files passed (22 tests, 59.57 s wall time). Changed-file format/lint passed. Independent subagent review (autoreview route unavailable) was scoped-clean at P0/P1/P2; the helper refused the configured provider mismatch before inference. The automated review correctly identified overly narrow wording/assertion in the regression: it now permits direct decoded-value identity and explicitly limits its claim to wrapper handoff. No accepted findings remain. The refined regression was rerun: base fails on the extra wrapper, candidate passes all four reply tests (78.98 s wall, including worker fixture compilation). Exact-head CI run 40259966088 passed on
a6fea445adae538ddd60d561522c779c7b76d1f1, including all PostgreSQL conformance shards and the CI gate job. ClawSweeper reviewed that same head with no actionable findings and no before-merge requirements; its owner-only proof and diagnostic-handoff-test caveats are explicitly retained above. Ready for maintainer handoff; intentionally left unmerged.Prior head
8345056b1ac68987517460cfe4c616e58f6182e3hit a UI-only failure in CI job 121367137069:chat-nested-tool-presentation.e2e.test.ts:135,diagnostics.isVisible()returned false. Its mocked Gateway/browser path does not exercise this SQLite reply owner. No UI fix or successful-retry attribution is claimed; the subsequent push addresses the independently reviewed test assertion above.