1 of 14

ZFS Compression

Jing, mqjing@gmail.com

2 of 14

現代的 file system 非常的強大,除了上次介紹的 zfs deduplication (自動用 hash code 代替重復的 blocks, 以達成有效利用儲存空間). 還有 snapshot 功能,你可以隨時回復上一動。另外,還有 on the fly的自動壓縮功能。你可以指定專門存放 VM image 的 pool 用 deduplication, user home pool 用 lz4 壓縮,專門放 user data 的 pool 使用 deduplication + compression. 巨量的節省使用空間。

想驗證,只要比對 ls 與 du 的結果,就能知道你的成效。身在這個時代,真好^_^

3 of 14

Introduction

  • Compression is transparent with ZFS if you enable it
  • ZFS is compressing and decompressing the data on disk on the fly
  • Supported compression algorithm
    • LZJB, LZ4, ZLE and gzip

4 of 14

LZ4 Performance*

  • ~50% faster on compression of compressible data
  • ~80% faster on decompression of incompressible data
  • Over 300% faster on compression of incompressible data
  • +10% higher compression ratio on the larger block size

* DataSet: Silesia Corpus test set

* The testing zpool was backed by a ramdisk so as to avoid hitting any IO subsystem bottlenecks and show pure LZ4 on ZFS throughput

5 of 14

Introduction

  • ZFS compression not only save space, but also improves performance
    • Because the time it takes to compress and decompress the data is quicker than the time it takes to read/write the uncompressed data to disk
  • Command
    • zfs set compression=on <pool name>
    • All child dataset of <pool name> will inherit the setting
  • Note
    • Only new data written after turning on compression is effected

6 of 14

How to check compression property

Enable

zfs get compressratio <pool>

7 of 14

Check the difference in size

zfs create -o compression=off rpool/test

cd /rpool/test

cp /bigfile bigfile1

zfs set compression=on rpool/test

cp /bigfile bigfile2

8 of 14

Check the difference in size

zfs get compressratio rpool/test

du -hs big*

ls does not show the compressed file size!

9 of 14

Another example

10 of 14

Check the performance in time

Command

time dd if=/dev/urandom of=/target.txt bs=1M count=1024

11 of 14

Check the I/O performance

Throughput

Command

sudo zpool iostat -v

12 of 14

Upgrade ZFS

Command

sudo zfs upgrade my_pool

Example

13 of 14

References

14 of 14

Further Information