Pcornel
Storage · ZFS

Compression

Cheat sheet · https://pcornel.dk/topic.php?topic=4026

Back to the Topic

Answer

ZFS can compress blocks before writing them and stores the compressed representation when beneficial according to the selected algorithm/policy. Compression can reduce physical I/O and capacity consumption, sometimes improving performance, but CPU cost and workload compressibility matter. Existing blocks keep their old representation until rewritten.

Remember

  • Compression ≠ deduplication.
  • Logical dataset size ≠ physical allocated bytes with compression.
  • Changing compression property ≠ recompressing all existing data immediately.
  • Higher compression ratio ≠ automatically lower application latency.

First checks

  • zfs get compression,compressratio <ds> — setting and ratio
  • zfs set compression=lz4 <ds> — enable lz4
  • zfs set compression=zstd <ds> — stronger compression

Verify in this order

write → compress → fewer blocks

Where it usually breaks

First mismatch in member media → metadata/layout → allocation/placement → redundancy/recovery → logical object → consumer; preserve identity/pre-state before mutation.

ZFS → Compression ZFS map

ZFS boundaryWhat to verifyProof limit
Identity / topologyPool GUID/name, dataset/zvol, top-level vdev class, leaf-device identity and effective propertiesObject presence alone does not prove integrity, performance or recovery
Capacity / protectionPool free space, quotas/reservations, snapshot retention, redundancy and active scrub/resilver stateFree space or ONLINE state at one layer does not prove end-to-end health
Failure boundaryA reported compression ratio proves a relationship between logical and stored representation for covered data; it does not prove CPU cost, future ratios or application performance.Correlate ZFS evidence with both workload and lower device/path evidence
AcceptanceHealthy evidence: selected compression policy matches workload, physical I/O/allocation improves or remains acceptable, CPU headroom exists, and representative reads/writes are correct.Close only after original workload plus checksum/read-back/recovery verification succeeds

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4026

Confirmation

Confirm action

Continue?