fix(versiondb): compress flushed sst files #137
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 224 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.324
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #137"
general
weight: 0.35
thomas-nguy
What
Versiondb SST files at L0 and the base level (the level L0 compacts into) are now ZSTD compressed instead of uncompressed. The SST file writer used by
build-versiondb-sstis unchanged. Also includes #139, a test-only fix:TestRewriteSnapshotBackgroundPreservesCacheSizenow closes its db so the prune goroutine finishes beforet.TempDircleanup.Issue
OptimizeLevelStyleCompactionleaves L0 and the base level uncompressed. Flushed files that overlap nothing below, which is howrestore-versiondbwrites, are moved to the bottommost level as is and stay uncompressed. On the 2026-10-09 mainnetversiondb-prunedsnapshot, 6.73 of 8.05 GB (84%) is uncompressed.Solution
compression_per_levelis ZSTD for L0 and the base level and LZ4 below; the bottommost level keeps ZSTD level 12 with a dictionary. Existing dbs need no migration.With
level_compaction_dynamic_level_bytes, RocksDB appliescompression_per_level[1]to the base level, not to the physical L1. Levels between L1 and the base level stay empty.On 12.5M mainnet EVM entries (1.33 GB raw) through
Store.Import:| L0 and base level | after flush | after compactions | compaction time |
|---|---|---|---|
| none (current) | 1.06 GB | 0.55 GB | ~46 s |
| LZ4 | 0.46 GB | 0.38 GB | ~45 s |
| ZSTD | 0.38 GB | 0.38 GB | ~0 s |
Commit latency is unchanged, since compression runs in the background flush: over 6,000 blocks of 1,000 EVM writes, both settings gave ~6.8 ms mean and ~8.5–9 ms p99 per block.
Test
TestFlushedFilesAreCompressed: flushed SST size is 0.97× raw before the fix, 0.087× after.cronosdfrom cronosmainwith this branch), switched from master: starts cleanly, historical queries match, new flushes are ZSTD, old uncompressed files still read.