Skip to content

perf: drain SQLite operations through a native FIFO - #369

Open
chrispader wants to merge 6 commits into
mainfrom
codex/native-operation-fifo
Open

chrispader wants to merge 6 commits into
mainfrom
codex/native-operation-fifo

Conversation

@chrispader

@chrispader chrispader commented Sep 18, 2026

Copy link
Copy Markdown
Member

On a single open database, each async query used to wait for its predecessor's result to return through JavaScript before submitting native work. Batches and file imports had the same gap, and setImmediate delayed each handoff. This PR submits async queries, batches, and file imports directly to a native FIFO on the connection while retaining the JavaScript queue for transaction callbacks and lifecycle guards.

One native worker drains each connection's jobs in submission order. A batch or file import remains one atomic native job. The JavaScript queue waits for earlier jobs before starting a transaction callback and holds later jobs until it commits or rolls back. Synchronous transaction methods reject while tx.executeAsync is pending; if the callback exits with pending queries, it waits for them and rolls back. An exception while settling one native promise no longer strands later jobs. Synchronous operations and close still report a busy connection while work is pending.

This branch targets main independently of #364. The iOS build job uses a generic simulator destination so it can compile without a named simulator installed on its runner.

Reproduction

The device harness holds a transaction after an insert, submits 24 external writes, then rolls back. The transaction's row disappears and all 24 external rows remain. Another case submits 24 writes before a transaction and checks that the transaction sees every row.

The harness also checks 64 native async inserts for submission order, verifies that a failed batch rolls back without affecting async statements on either side, and confirms that a failed native query does not stop the FIFO. Unit tests cover pending transaction queries and immediate submission of batches and file imports.

The scheduling change addresses the Promise.all workload in the Expensify App review. An Expensify App TTI comparison on low-end iOS and Android devices remains necessary to measure its effect on startup.

@vercel

vercel Bot commented Sep 18, 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 Sep 23, 2026 12:11pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview 0976b18a Deployed Sep 23, 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