Skip to content

perf: begin deferred transactions synchronously - #501

Open
chrispader wants to merge 1 commit into
async-overhead/transaction-promise-layersfrom
async-overhead/sync-begin
Open

chrispader wants to merge 1 commit into
async-overhead/transaction-promise-layersfrom
async-overhead/sync-begin

Conversation

@chrispader

@chrispader chrispader commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Every transaction started by awaiting BEGIN TRANSACTION through executeAsync(), which sends the statement to the connection's worker thread and waits for the result to come back to JavaScript. COMMIT and ROLLBACK already run synchronously. In a per-call probe on a Galaxy S10, one async point read awaited on its own took 0.6 to 1 ms, against about 0.1 ms per read with many reads in flight.

A deferred BEGIN takes no lock and returns immediately, so it now runs synchronously like COMMIT. The callback still starts after transaction() returns, one microtask later instead of after the round trip. BEGIN EXCLUSIVE TRANSACTION, used when NitroSQLite.transaction() gets isExclusive, stays async because it can wait for another connection's lock.

🤖 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 transaction awaited BEGIN through executeAsync, a round trip to the connection's worker thread and back, while COMMIT and ROLLBACK already ran synchronously. A deferred BEGIN takes no lock and returns at once, so it now runs synchronously too. The callback still starts after transaction() returns, one microtask later instead of after the round trip. BEGIN EXCLUSIVE stays async because it can wait for another connection's lock.

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

This branch was successfully deployed

1 active deployment
Preview — 8fd97e38 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