← Back to Pull requests

fix(versiondb): compress flushed sst files #137

Closed
unknown closed this pull request without merging on Oct 15, 2026 18:39 UTC
View on GitHub
unknown unknown commented on Oct 09, 2026 16:03 UTC
Author

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-sst is unchanged. Also includes #139, a test-only fix: TestRewriteSnapshotBackgroundPreservesCacheSize now closes its db so the prune goroutine finishes before t.TempDir cleanup.

Issue

OptimizeLevelStyleCompaction leaves L0 and the base level uncompressed. Flushed files that overlap nothing below, which is how restore-versiondb writes, are moved to the bottommost level as is and stay uncompressed. On the 2026-10-09 mainnet versiondb-pruned snapshot, 6.73 of 8.05 GB (84%) is uncompressed.

Solution

compression_per_level is 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 applies compression_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.

  • Devnet node (cronosd from cronos main with this branch), switched from master: starts cleanly, historical queries match, new flushes are ZSTD, old uncompressed files still read.
  • Diff: 224 lines (+168 / -56) across 2 files Reviewer: thomas-nguy Review duration: 8795m
    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
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.9% (MEDIUM) · Higher = larger blast radius
    36.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.6% · Safe to merge
    14.6%