Skip to content

improve: speed up SQLite reads on Node 24.20 - #149769

Merged
steipete merged 1 commit into
mainfrom
codex/sqlite-node24-bulk-0916
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/sqlite-node24-bulk-0916

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #147862

What Problem This Solves

SQLite reads on Node 24.20 still build their result arrays through JavaScript iteration even though that release includes the native bulk-read correctness fix.

User Impact

Reduces warm SQLite result-read overhead on Node 24.20 and later Node 24 releases. Older Node 24 releases retain the existing safe fallback; the minimum supported Node version is unchanged.

Why This Change Was Made

Extend the existing all() eligibility check to the Node 24.20 backport. The upstream implementation obtains column counts after stepping, so cached queries preserve newly added columns after SQLite reprepares them. Native statement ownership, bindings, error handling, lazy iteration, and transactions remain with their existing owners.

Evidence

  • 36 existing SQLite helper tests passed on an isolated, checksum-verified Node 24.20.0 / SQLite 3.53.4 runtime, including schema reprepare, errors/reset, returning rows, reentry, authorization changes, and disposal.
  • Full-owner paired correctness passed on actual Node 24.19.0, 24.20.0, and 26.8.2. SQL, bindings, results and errors matched. Method tracing confirmed that only the Node 24.20 candidate switched from iterate() to all(). All 12 handles closed.
  • Fixed warm in-memory experiment: eight cells (0/1/100/2,000 rows, numeric/text), three warmup pairs and seven measured pairs each. Median paired reductions were 40.4–60.5%; every nonempty cell improved in all seven pairs. All 80 pairs were retained and all 16 timing handles closed.
  • The empty text cell retained two slower pairs (+62.0% and +28.8%) while its paired median improved 51.2%. These are executor component measurements on a shared Windows host, not whole-Gateway or disk-I/O speedups. No samples were discarded or rerun for favorable numbers.
Rows Numeric median paired reduction Text median paired reduction
0 57.7% 51.2%
1 40.4% 44.9%
100 60.5% 46.7%
2,000 60.2% 56.1%

Formatting, diff checks, and targeted type-aware lint passed. Independent review found no actionable findings through P2. Exact-head hosted CI 35061297642 passed, including required openclaw/ci-gate. Completed independent and ClawSweeper reviews have no actionable findings; native landing checks remain authoritative.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 16, 2026 05:52
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 16, 2026
@steipete steipete self-assigned this Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:31 AM ET / 06:31 UTC (Revision 2).

ClawSweeper review

What this changes

Enable faster native SQLite result collection on Node 24.20 and later Node 24 releases while retaining the existing fallback on older runtimes and Bun.

Merge readiness

✅ Ready for maintainer review

Keep open: the optimization remains absent from current main, and the narrow runtime gate matches Node’s backported fix. No actionable correctness or security findings remain.

Priority: P2
Reviewed head: 2d3549e4873cfb3f82d1c0f8c8e8da0d81206cf0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable optimization with relevant real-runtime evidence and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured PR evidence describes the production SQLite executor running on three actual Node versions, with equivalent results and errors, the intended Node 24.20 collector switch, and measured after-fix improvements on a Windows host; existing tests supplement that runtime evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR evidence describes the production SQLite executor running on three actual Node versions, with equivalent results and errors, the intended Node 24.20 collector switch, and measured after-fix improvements on a Windows host; existing tests supplement that runtime evidence.
Evidence reviewed 7 items Verified introduced change: The merge-base-to-head diff changes only the runtime eligibility predicate. Node 24.20+ is admitted only within major 24; the existing Node 26.6+ threshold and Bun exclusion remain.
Dependency contract verified: The direct node:sqlite import and PR’s backport claim establish the Node dependency boundary. At the verified v24.20.0 commit, StatementExecutionHelper::All obtains column counts after sqlite3_step; StatementSync::All also resets the statement on scope exit. See the Node implementation.
Current main still needs the extension: Fetched main permits native bulk collection only on Node 26.6+, so Node 24.20 still takes the iterator path.
Findings None None.
Security None None.

How this fits together

OpenClaw’s synchronous SQLite executor turns compiled database queries and bound parameters into result rows for storage consumers such as session history. This change selects the native result collector without changing query construction or database lifecycle ownership.

flowchart TD
  A[Storage queries and parameters] --> B[Shared SQLite executor]
  B --> C[Existing statement cache]
  C --> D{Supported native collector?}
  D -->|Yes| E[Native bulk read]
  D -->|No| F[Iterator collection]
  E --> G[Result rows]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1. Total -1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 5 6 -1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 5 6 -1

Review metrics

None.

Technical review

Best possible solution:

Keep runtime selection inside the shared executor and use native collection only on Node releases with the reprepare fix.

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

Not applicable as a correctness bug: this is a performance optimization, supported by source-confirmed path selection and reported paired real-runtime measurements.

Is this the best way to solve the issue?

Yes. Extending the existing version gate is the narrowest solution and preserves established query, caching, fallback, and lifecycle contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7141bded36b3.

Labels

Label justifications:

  • P2: This is a bounded performance improvement for SQLite reads on a supported Node release line.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured PR evidence describes the production SQLite executor running on three actual Node versions, with equivalent results and errors, the intended Node 24.20 collector switch, and measured after-fix improvements on a Windows host; existing tests supplement that runtime evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR evidence describes the production SQLite executor running on three actual Node versions, with equivalent results and errors, the intended Node 24.20 collector switch, and measured after-fix improvements on a Windows host; existing tests supplement that runtime evidence.

Evidence

What I checked:

  • Verified introduced change: The merge-base-to-head diff changes only the runtime eligibility predicate. Node 24.20+ is admitted only within major 24; the existing Node 26.6+ threshold and Bun exclusion remain. (src/infra/kysely-sync.ts:20, 2d3549e4873c)
  • Dependency contract verified: The direct node:sqlite import and PR’s backport claim establish the Node dependency boundary. At the verified v24.20.0 commit, StatementExecutionHelper::All obtains column counts after sqlite3_step; StatementSync::All also resets the statement on scope exit. See the Node implementation. (src/node_sqlite.cc:2887, 71b8b174857e)
  • Current main still needs the extension: Fetched main permits native bulk collection only on Node 26.6+, so Node 24.20 still takes the iterator path. (src/infra/kysely-sync.ts:20, 7141bded36b3)
  • Latest release comparison: The supplied latest release, v2026.9.4, uses iterator collection without this native eligibility gate. Its source was verified through GitHub after the local release blob was unavailable. (src/infra/kysely-sync.ts:80, 3a9d69db306c)
  • Merged predecessor and routing history: GitHub verifies improve: reduce CPU during SQLite result reads #147862 as merged. Its commit adds the existing native collector for Node 26.6+, making it related groundwork rather than a replacement for the Node 24 extension. GitHub’s commit patch and raw local parent record support the history; local blame and some historical blob reads were unavailable. (src/infra/kysely-sync.ts:99, a9bc6386225a)
  • Existing contract coverage: The complete executor and test module were inspected. Existing tests cover cached schema reprepare, eager and lazy results, changing bindings, callback reentry, authorizer transitions, step-error recovery, and disposal. No tests were executed during this read-only review. (src/infra/kysely-sync.test.ts:522, 2d3549e4873c)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-09-16T06:02:26.511Z sha 2d3549e :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 4295167 into main Sep 16, 2026
265 checks passed
@steipete
steipete deleted the codex/sqlite-node24-bulk-0916 branch September 16, 2026 06:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant