Skip to content

sqlite: use shared-shape objects for result rows - #66385

Open
araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:sqlite-shared-shape-rows
Open

araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:sqlite-shared-shape-rows

Conversation

@araujogui

Copy link
Copy Markdown
Member

all(), get() and iterate() built each row with the Object::New() overload that takes names and values. That overload always returns a dictionary-mode object, so no two rows shared a map and every property read was a hash lookup.

Rows are now built from a DictionaryTemplate cached on the statement and invalidated on re-prepare. Rows keep their null prototype. Statements whose column names a template can't express (array indices, duplicates, non-ASCII names, which the template interns as Latin-1) or with more than 64 columns keep the previous path.

Adds benchmark/sqlite/sqlite-prepare-select-read.js, which reads every column of each row, since the existing benchmarks only measure building rows.

Fixes: #65799

Copilot AI balanced review requested due to automatic review settings September 28, 2026 23:40
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/sqlite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Sep 28, 2026
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.40%. Comparing base (9746ebc) to head (46793f9).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 85.00% 4 Missing and 5 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66385   +/-   ##
=======================================
  Coverage   90.40%   90.40%           
=======================================
  Files         791      791           
  Lines      276120   276141   +21     
  Branches    53022    53026    +4     
=======================================
+ Hits       249618   249644   +26     
+ Misses      16897    16895    -2     
+ Partials     9605     9602    -3     
Files with missing lines Coverage Δ
src/node_sqlite.h 87.27% <ø> (ø)
src/node_sqlite.cc 82.11% <85.00%> (+0.22%) ⬆️

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trivikr

trivikr commented Oct 5, 2026

Copy link
Copy Markdown
Member

@araujogui Can you run the benchmark CI and post output here?

CI currently fails on summarizing the output. You can copy the raw output and summarize it locally.

`all()`, `get()` and `iterate()` built each row with the
`Object::New()` overload that takes names and values. That overload
always returns a dictionary-mode object, so no two rows shared a map
and every property read was a hash lookup.

Build rows from a `DictionaryTemplate` cached on the statement in place
of the column names, invalidated on re-prepare. Rows keep their null
prototype. Statements whose column names a template cannot express
(array indices, duplicates, non-ASCII names, which the template
interns as Latin-1) or with more than 64 columns keep the previous
path.

Add a benchmark that reads every column of each row, since the
existing ones only measure building rows.

Fixes: nodejs#65799
Assisted-by: Claude
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
@araujogui
araujogui force-pushed the sqlite-shared-shape-rows branch from a61d7f8 to 46793f9 Compare October 6, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-benchmark-ci PRs that need a benchmark CI run. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite: remove the null prototype from result rows

4 participants