Skip to content

perf: send row batches to one registered handler - #504

Open
chrispader wants to merge 1 commit into
async-overhead/prepared-connection-workerfrom
async-overhead/row-batch-handler
Open

chrispader wants to merge 1 commit into
async-overhead/prepared-connection-workerfrom
async-overhead/row-batch-handler

Conversation

@chrispader

@chrispader chrispader commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Every managed executeAsync() passed a new onRows callback to native code, although native code only calls it for results of 256 rows or more. Nitro converts each callback into a native function and adds a weak reference to it to its JSI cache, which it never prunes, so every query pays for the conversion and the cache grows with the number of queries. In a per-call probe on an iPhone 14 Pro, passing the callback raised the cost of 250 point reads in flight from about 36 to about 54 µs per read.

The managed API now sets one handler with the new setRowBatchHandler() native method and passes a numeric rowBatchId per query instead. Native builds without setRowBatchHandler() still get a callback per query.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-nitro-sqlite Ready Ready Preview Nov 16, 2026 4:34pm UTC

Request Review

Every managed executeAsync passed a new onRows callback to native code, even though native only calls it for results of 256 rows or more. Nitro converts each callback to a native function and keeps a weak reference to it in its JSI cache, which is never pruned. The managed API now sets one handler with setRowBatchHandler and passes a numeric row batch ID per query. Native builds without the handler still get a callback per query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 51ed4eb3 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant