Expand description
L2 Blob Compressor.
Stateless, deep module encapsulating compression of blob payloads spilled to
the L2 (on-disk) tier of [BlobCache]. The purpose is to shrink durable blob
footprints without harming hot-path latency or wasting CPU on payloads that
are already incompressible.
§Design
The module is intentionally small and side-effect free:
- All operations are static — no internal state, no allocator pinning, no
threading concerns. Inputs are
&[u8]slices, outputs are ownedVec<u8>. - Compression is best-effort: when the input is small, when the content type
already represents a compressed media format, or when the
zstdoutput fails to shrink the input meaningfully, the original bytes are returned insideCompressed::Rawand no encode is performed (or its result is discarded). - The compressed variant carries the original byte length so decompression can pre-allocate exactly and verify the encoded length on decode.
Wiring into [BlobCache] L2 put/get is performed in a follow-up slice;
this module is additive and has no callers in this commit.
Structs§
- Compress
Opts - Configuration knobs for
L2BlobCompressor::compress. - L2Blob
Compressor - Stateless compressor for L2 blob payloads.
Enums§
- Compress
Error - Errors produced by the compressor.
- Compressed
- Storage-ready representation of a blob payload after the compressor has
inspected it.
Rawis byte-equivalent to the input;Zstdcarries an encoded payload plus the original byte length for verification.
Constants§
- DEFAULT_
MAX_ RATIO - Default cutoff ratio above which the compressed bytes are discarded.
0.95means we require at least a 5% reduction to keep the encoded form. - DEFAULT_
MIN_ BYTES - Default minimum payload size eligible for compression. Sub-kilobyte payloads rarely benefit and the framing overhead can exceed any savings.
- DEFAULT_
ZSTD_ LEVEL - Default
zstdcompression level — favours encode speed over ratio. The L2 tier is meant to amplify capacity, not to be the smallest possible store.