This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
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.
!!! early draft, full of debug prints, barely works !!!
This draft contains experiments around deduplicating our own
wallog
format with libSQL WAL. The potential win here is reducing write and space amplification from 2x to around 1.08x.The main idea is as follows:
wallog
is only used to store frame metadata, and frame data is only stored either in the main database file, or in WAL. That's very simple to implement in a single-node system, but it gets complicated with replicas, because a replica is allowed to ask the primary for any arbitrary wallog frame.The rough idea for dealing with replicas is to:
wallog
, and instead only store the following information. Let's assume that the main db file has N pages. Pages 1..N are now available as frames X..X+N in thewallog
, and X is the oldest frame a replica should ever ask for -> anything before X is out-of-date anyway. If any replica asks for an earlier page, it gets an error message saying "please drop whatever you're doing and start asking for frames X or greater instead.