Skip to content

feat: Add Memtable Byte Size And Flush Threshold - #6

Merged
ThomasHartDev merged 2 commits into
mainfrom
thomas/feat/memtable
Sep 17, 2026
Merged

ThomasHartDev merged 2 commits into
mainfrom
thomas/feat/memtable

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

The memtable was a bare BTreeMap, so the store had no payload-byte count and no signal for when to flush. This pulls it into its own type, charges key+value bytes on insert, overwrite, and delete, and exposes should_flush against a configurable write_buffer_size (default 4 MiB).

Overwrite uses saturating_sub/add so a shrink cannot wrap the counter. WAL replay applies the same put/delete path, so size_bytes after open matches the live store. A zero buffer is rejected before any directory or WAL file is created. Actual SSTable flush is the next slice.

Closes #5

Track key+value bytes incrementally on the BTreeMap memtable and
signal should_flush once size crosses write_buffer_size.
Construct the memtable first so a zero write_buffer_size fails
without mkdir or wal.log. README size_bytes for user:1/ada is 9.
@ThomasHartDev
ThomasHartDev merged commit def0bca into main Sep 17, 2026
1 check passed
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.

Track memtable byte size and add a flush threshold signal

1 participant