This script stress-tests Btrfs compression modes using a real 1.5 GiB mixed file sample by mounting different file system configurations and testing disk I/O.
Each pass will remount the entire filesystem cold and drops caches, so results stay comparable.
It randomly samples bits from my ~ directory to create a realistic, mixed-entropy test dataset.
The only numbers that really matter are wr_eff and rd_eff — they reflect what you’ll feel in practice. It essentially shows where compression helps and where your CPU becomes the bottleneck.
Results:
❯ sudo ./a.zsh
algo ratio c_time d_time wr_raw rd_raw wr_eff rd_eff
none 1.00x 0.0s 0.0s MiB MiB 580MiB 315MiB
lzo 4.80x 1.0s 0.7s MiB MiB 258MiB 219MiB
zlib:1 6.49x 3.1s 0.9s MiB MiB 116MiB 186MiB
zlib:5 8.00x 6.2s 0.8s MiB MiB 65MiB 207MiB
zlib:9 8.43x 29.8s 0.8s MiB MiB 15MiB 204MiB
zstd:1 7.94x 1.5s 0.4s MiB MiB 195MiB 241MiB
zstd:3 8.94x 1.9s 0.4s MiB MiB 171MiB 237MiB
zstd:6 10.30x 5.0s 0.4s MiB MiB 78MiB 249MiB
zstd:9 11.07x 7.0s 0.3s MiB MiB 58MiB 245MiB
zstd:15 11.75x 50.4s 0.3s MiB MiB 9MiB 254MiB
~ 2m 15s root@localhost
❯
Columns:
- ratio = space saved
- c_time = compress time
- d_time = decompress time
- wr_eff = true write speed (CPU + disk)
- rd_eff = true read speed (CPU + disk)