What the Compressed Size Includes

An encoded result can contain payload, metadata, and padding. Comparing only payload bits may overstate the savings.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Compute a small result
  2. Choose a fair baseline
  3. Solve the break-even point in a simple overhead model
  4. Report total bytes at the real storage boundary

Compute a small result

A payload of 19 bits requires three whole bytes if its final byte is padded. Adding a two-byte header brings the stored size to five bytes in this example. See quotient and remainder.

Choose a fair baseline

Compare complete artifacts supporting the same decode contract. A dictionary or format marker adds real size. File byte lengths provide the physical measurement.[1][2]

Solve the break-even point in a simple overhead model

If payload compression uses six bytes for every ten original bytes and metadata takes twelve bytes, approximate compressed size is \(0.6n+12\). Strict saving under this model requires \(n>30\). Actual padding and record boundaries can shift the exact threshold. See when compression increases size.

Raw 20 → payload 12 + header 12 = 24
Raw 30 → 18 + 12 = 30
Raw 50 → 30 + 12 = 42

Report total bytes at the real storage boundary

Include checksums, dictionaries and padding where applicable. Compare the result with the actual raw representation, including metadata it would also require.

References

  1. Claude E. Shannon, A Mathematical Theory of Communication ↩
  2. David J. C. MacKay, Information Theory, Inference, and Learning Algorithms ↩