Batch SQLite db-apply transactions#248
Draft
adamziel wants to merge 3 commits into
Draft
Conversation
Contributor
Pull pipeline performance —
|
| Stage | PR | trunk | Δ | Status | Details |
|---|---|---|---|---|---|
playground-sqlite-db-pull |
7.26 s | 7.36 s | ⚪ -93 ms (-1.3%) | ✓ | condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected trunk: condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected |
playground-sqlite-db-apply |
2.62 s | 2.82 s | ⚪ -201 ms (-7.1%) | ✓ | condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified trunk: condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified |
| Total | 9.88 s | 10.18 s | ⚪ -294 ms (-2.9%) |
Numbers carry runner noise; treat single-run deltas as directional, not authoritative.
📈 Trunk performance history — commit-by-commit timeline.
89a7e31 to
2201c8d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Batches the SQLite
db-applypath inside one simple wrapper-transaction model. SQLite now opens an import-owned transaction, commits every 500 applied statements, and writes_reprint_db_apply_progressin the same transaction as the target data.Rationale
The previous version tried to support both source dump transaction boundaries and importer batch transactions. That made the PR much larger: separate statement classification, DDL/SET flushing, transaction state tracking, and helper methods for a path that only exists to speed up SQLite imports.
This version goes all-in on importer-owned batches. MySQL dump transaction-control statements are counted for resume offsets but skipped on SQLite, because executing
START TRANSACTION,COMMIT,ROLLBACK,LOCK,UNLOCK,SAVEPOINT, orRELEASEwould let the MySQL-on-SQLite wrapper commit or roll back behind the importer’s progress marker.The native MySQL parser does not make this change irrelevant. It speeds up parser/translation work inside MySQL-on-SQLite. This PR reduces SQLite transaction/progress-commit overhead. Those are different layers. With the native parser enabled, and with CI’s small fixture, less wall time remains for batching to remove, so the reported delta is smaller.
Implementation
The SQLite path now does the minimum needed for atomic batched resume:
_reprint_db_apply_progressonce before streamingdb.sql.SQLITE_DB_APPLY_BATCH_SIZEstatements and at the end of the stream.WP_MySQL_Lexercheck only for possible transaction-control statements; normalINSERTstatements avoid tokenization.Compared with the prior PR head, the consolidation removes the statement-classification helpers and deletes 481 lines while adding 209 lines for the simplified code and adjusted adversarial coverage.
CI performance report for this head SHA uses the small fixture (
10,000posts /25,000postmeta) with the native parser extension enabled:playground-sqlite-db-applyThe larger local focused benchmark below uses the default large fixture (
320,007posts /720,015postmeta) with no native parser extension. It is not expected to match the bot comment; it isolates the batching payoff under a much larger statement count:origin/trunkplayground-sqlite-db-applyplayground-sqlite-db-applyTesting instructions