Compression
Cheat sheet · https://pcornel.dk/topic.php?topic=4026
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 ratiozfs set compression=lz4 <ds>— enable lz4zfs 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 boundary | What to verify | Proof limit |
|---|---|---|
| Identity / topology | Pool GUID/name, dataset/zvol, top-level vdev class, leaf-device identity and effective properties | Object presence alone does not prove integrity, performance or recovery |
| Capacity / protection | Pool free space, quotas/reservations, snapshot retention, redundancy and active scrub/resilver state | Free space or ONLINE state at one layer does not prove end-to-end health |
| Failure boundary | A 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 |
| Acceptance | Healthy 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