Skip to content

Compress execution details with an embedded Zstd dictionary #69

Description

@bmuddha

Goal

Reduce ledger execution-detail frame size by embedding the selected universal Zstd dictionary, omitting redundant per-frame dictionary IDs, and making the superblock format version the compatibility boundary.

Why

The ledger bitcode-encodes Option<ExecutionDetails> and compresses each value as an independent Zstd frame. The selected curated hybrid dictionary was trained and validated against a deterministic 60,000-sample corpus with identifier-churn scenarios to retain useful structural and runtime vocabulary without overfitting to incidental program IDs.

On the untouched random holdout, dictionary-backed level-3 Zstd reduced output from 16.39% to 10.59% of the uncompressed bitcode size, a 35.37% saving relative to level-3 Zstd without a dictionary. Savings remained 27.27% for future-20% approved-program traffic, 25.37% with zero approved-program traffic, and 30.28% with high-50% approved-program traffic. The universal score is 27.39%.

Scope

  • Keep the selected 1,280-byte artifact at assets/execution-details.dict with SHA-256 9f9f91c856f04c0899b3b5fb3174a1b020608f321d3a7d2bd42491dd310c4c9d.
  • Embed it in the ledger crate with include_bytes!() and use an explicit compression level of 3.
  • Load the dictionary once when each reusable appender and reader Zstd context is initialized; preserve the existing bitcode layout and direct compress_to_buffer file-buffer path.
  • Disable the Zstd frame dictionary-ID flag and verify representative frames omit dictionary IDs while matching Zstd and bitcode contexts still round-trip.
  • Store immutable ledger version 1 first in every superblock.meta and reject unsupported versions before opening or creating the superblock index and data files.
  • Treat the dictionary and codec as part of the versioned ledger format. Any future dictionary or codec change requires a ledger-version bump and explicit compatibility handling; no dictionary-less fallback or migration is included.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions