Commit 37a8e0e
committed
Add opt-in Snappy page compression to reduce database size
Introduce a `Compression` option on DB/Options that enables transparent
Snappy compression of leaf and branch page data. Compression happens at
node spill time—before page allocation—so fewer pages are allocated for
compressible data. Decompression is transparent on read via a
per-transaction cache using sync.Map for concurrent reader safety.
Key changes:
- New orthogonal CompressedPageFlag (0x20) on page headers; type checks
changed from == to bitwise & so the flag coexists with page types
- CompressInodes serializes and compresses node data, only used when it
reduces the page count
- Split threshold increased 4x when compression is enabled so nodes
accumulate enough data for meaningful compression
- DecompressPage preserves on-disk overflow for correct freelist accounting
- Adds github.com/golang/snappy dependency
This was largely written by Claude Opus.
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>1 parent 39fc24c commit 37a8e0e
File tree
11 files changed
+987
-17
lines changed- internal/common
11 files changed
+987
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
887 | 892 | | |
888 | 893 | | |
889 | 894 | | |
| |||
945 | 950 | | |
946 | 951 | | |
947 | 952 | | |
948 | | - | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
949 | 961 | | |
950 | 962 | | |
951 | 963 | | |
| |||
0 commit comments