-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snapshot checkpointing #710
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #710 +/- ##
==========================================
- Coverage 85.74% 81.10% -4.65%
==========================================
Files 197 197
Lines 29040 29048 +8
Branches 4084 4059 -25
==========================================
- Hits 24901 23558 -1343
+ Misses 3915 3844 -71
- Partials 224 1646 +1422 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Marco! As discussed on MM I think this change is sound and the implementation looks good to me. I have a few style-related nits but with your permission I'll fix them by adding a commit directly to this branch instead of leaving comments.
src/vfs.c
Outdated
} else if (sqlite3_stricmp(left, "wal_checkpoint") == 0 | ||
|| (sqlite3_stricmp(left, "wal_autocheckpoint") == 0 && right)) { | ||
fnctl[0] = sqlite3_mprintf("custom checkpoint not allowed"); | ||
return SQLITE_IOERR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, thanks for thinking of this and adding it.
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
This PR aims at reducing the amount of memory required for a snapshot and removing entirely page allocation from it.
The main idea is not to save the WAL during a snapshot as it is not necessary to do so. Instead, we can apply pages in the WAL to the database being saved. This means that the snapshotting logic will not allocate memory for pages, but just for the buffer list and the headers.
The saving in terms of memory and write size is in the order of
0 - 4MiB
(unless a very big transaction happened) as the current implementation has a threshold of 1000 pages in the WAL before trying to checkpoint.While the gain is quite small in absolute terms, it can become important when the size of the database is small, which seems to be likely.