pub enum AutoTier {
Fast,
Balanced,
Small,
}enc only.Expand description
Which codecs a selection pass is allowed to try.
Compression runs once, in the proc macro; decompression runs in every consumer’s shipped binary on every access. The two are not interchangeable costs, so the tiers cut the codec set by decode speed and each keeps the smallest output within its own candidates. Measured on a 125,976-byte executable, with the decoders this crate actually ships:
| tier | wins with | payload | decode |
|---|---|---|---|
Fast | LZ4 | 81,798 B | 2,775 MB/s |
Balanced | Zstd | 56,140 B | 112 MB/s |
Small | LZMA | 52,512 B | 41 MB/s |
The tiers are nested, so a wider one never picks a larger payload than a narrower one. They are fixed membership rather than a cost function: which codec a build selects has to be predictable from the asset and the enabled features alone, never from how fast the build machine is.
The tier is a build-time policy. An entry header records the one
CodecId that won, so nothing about it reaches the decode side.
Variants§
Fast
Store, Lz4, Snappy — the codecs that decode at GB/s.
Selected by codec = auto_fast. Also by far the cheapest to
encode: it runs neither the LZMA nor the Zstd encoder, both of
which search hard enough to cost minutes on a large, poorly
compressible asset. Measured on 32 MiB of such data: this tier took
0.2 s where Balanced took 180 s.
Balanced
Fast plus Deflate and Zstd.
Selected by codec = auto, and the balance point the auto family
is named for: roughly a third off the payload Fast picks, and
still read back around three times quicker than LZMA’s.
The balance is in decode speed, which the consumer’s binary pays on every access. It is not cheap to encode: Zstd parses each block by price over several passes, so a large asset costs this tier minutes at build time. See the README’s note on build times.