Bootstrap database file instead of pulling every WAL frame#2017
Merged
penberg merged 2 commits intotursodatabase:mainfrom Apr 8, 2025
Merged
Bootstrap database file instead of pulling every WAL frame#2017penberg merged 2 commits intotursodatabase:mainfrom
penberg merged 2 commits intotursodatabase:mainfrom
Conversation
Currently, the sync code pulls all the generations and frames one by one. However, this is very inefficient, for databases with many generations it could take hours. This patch adds a optimisation that it pulls the latest generation by calling `export` endpoint and boostraps the db file quickly. My testing shows insane improvements. For a db with 30 generations, and about 100 frames in each gen, it has brought down the initial sync from 1hr to 1 minute.
When syncctx is initialised, we will init the generation with 0 and let the sync_db to update it to the new value
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 10, 2025
This patch is a follow up on #2017 It changes the heuristics for bootstrapping the DB. One more change is, it also does bootstrap before any connection to the local SQLite is created Earlier, we bootstrapped whenever we noticed a change in the generation. However, this patch changes this behaviour and does bootstrap only if local files don't exist: 1. if no db file or the metadata file exists, then user is starting from scratch and we will do the sync 2. if the db file exists, but the metadata file does not exist (or other way around), then local db is in an incorrect state. we stop and return with an error 3. if the db file exists and the metadata file exists, then we don't need to do the sync
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.
Currently, the sync code pulls all the generations and frames one by one. However, this is very inefficient, for databases with many generations it could take hours.
This patch adds a optimisation that it pulls the latest generation by calling
exportendpoint and boostraps the db file quickly.My testing shows insane improvements. For a db with 30 generations, and about 100 frames in each gen, it has brought down the initial sync from 1hr to 1 minute.
Fixes #1991