Add snappy streaming compression to WAL segments#70
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #70 +/- ##
==========================================
- Coverage 60.45% 60.44% -0.01%
==========================================
Files 19 19
Lines 1613 1625 +12
==========================================
+ Hits 975 982 +7
- Misses 502 505 +3
- Partials 136 138 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Close #47
Why
WAL files grow rapidly under load . The root cause is that metric names are written uncompressed and repeated on every row, making WAL data highly compressible.
What
Introduce Snappy streaming compression to WAL segment files, targeting 2-3x file size reduction.
Changes:
snappy.Writerbetweenbufio.Writerandos.File(bufio → snappy → file)snappy.NewReaderfor transparent decompressionnewDiskWAL, punctuate, refresh, and removeAll
snappy.ErrCorrupttolerance in readAll() — Snappy's frame format is self-synchronizing, sopartial frames from a crash are safely skipped
Backward compatibility
WAL segments are deleted on clean shutdown, so no migration is needed. The only edge case is a crash during
upgrade, where old uncompressed segments would fail to read — this is acceptable.