I’ve been doing some testing around with some various different pool configurations on ZFS with some used SSDs I bought, and was about to settle on a particular config for my use cases, until I realised that my measurements…kind of seem off? Can someone help explain what might be going on so I can figure out whether or not I can trust the numbers?
For background: I’m working with 5-7 1TB (931.51GiB) SSDs for a low heat low activity disk array in my small PC, looking to replace a 2 disk RAID0 that gets really hot. It’s going to have a various number of datasets, but the bulk of it is mostly media, a lot of it for professional subtitling work and video editing. My priority is capacity over performance/reliability, but I don’t want to be forced to rebuild an array if a disk does fail if I can help it, so I’m planning on a raidz1 with cold spares that I can hotplug if necessary (I have 8 of these SSDs in total).
So in an attempt to find out what configuration would give me the best space efficiency, I tried creating 5, 6, and 7 raidz1 pools using ashift=13 (as selected by openzfs), and did some testing with the different compression options on datasets using recordsize=1M with one of the folders I’m moving over.
I’m using du -s here to measure the size of each dataset, but df and zfs list -p also report similar values:
| array | ratio |
du -s size |
algorithm |
|---|---|---|---|
| btrfs stripe | 1.0000x | 129.915 GiB | NONE |
| - | - | - | - |
| 6z1 | 1.0389x | 125.043 GiB | off |
| 6z1 | 1.1029x | 117.791 GiB | zstd-3 |
| 6z1 | 1.0712x | 121.274 GiB | zstd-fast |
| 6z1 | 1.0685x | 121.576 GiB | lz4 |
| - | - | - | - |
| 5z1 | 1.0000x | 129.911 GiB | off |
| 5z1 | 1.0613x | 122.410 GiB | zstd-3 |
| 5z1 | 1.0310x | 126.004 GiB | zstd-fast |
| 5z1 | 1.0284x | 126.317 GiB | lz4 |
| - | - | - | - |
| 7z1 | 1.0666x | 121.799 GiB | off |
| 7z1 | 1.1323x | 114.730 GiB | zstd-3 |
| 7z1 | 1.1407x | 113.881 GiB | zstd-19 |
| 7z1 | 1.0997x | 118.127 GiB | zstd-fast |
| 7z1 | 1.0970x | 118.420 GiB | lz4 |
Based on this, I was leaning on going with a 7 disk array and using zstd-3 because it seemed to shave off 15GiB compared to the size of the dataset on the original filesystem [0]. However, the uncompressed sizes differing between the different arrays do not really make sense to me. I would think they would all be 129GiB.
Then I tried bumping ashift down to 12. There, I noticed something: when it was 13 on the 7z1 array, zfs list reported total available space as 4.96T, but when it’s set to 12 it reported 5.23T (out of 6.36T):
$ sudo zpool create -f -o autotrim=on -o ashift=12 -O acltype=posix -O normalization=formD -O canmount=off -O dnodesize=auto -O compression=lz4 -O setuid=off -O atime=off -O xattr=sa -O overlay=off microcosm raidz1 /dev/disk/by-id/ata-Samsung_SSD_840_EVO_1TB_*
$ sudo zfs list | grep -P 'microcosm|NAME'
NAME USED AVAIL REFER MOUNTPOINT
microcosm 646K 5.23T 162K /microcosm
$ sudo zpool destroy microcosm
$ sudo zpool create -f -o autotrim=on -O acltype=posix -O normalization=formD -O canmount=off -O dnodesize=auto -O compression=lz4 -O setuid=off -O atime=off -O xattr=sa -O overlay=off microcosm raidz1 /dev/disk/by-id/ata-Samsung_SSD_840_EVO_1TB_*
$ sudo zfs list | grep -P 'microcosm|NAME'
NAME USED AVAIL REFER MOUNTPOINT
microcosm 1.16M 4.96T 307K /microcosm
$ sudo zpool list -v microcosm
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
microcosm 6.36T 1.59M 6.36T - - 0% 0% 1.00x ONLINE -
raidz1-0 6.36T 1.59M 6.36T - - 0% 0.00% - ONLINE
...
For the 5z1 array, it pretty much stayed at 3.6T (out of 4.55T). What would happen if I remade the different datasets again?
| array | ratio |
du -s size |
algorithm |
|---|---|---|---|
| btrfs stripe | 1.0000x | 129.915 GiB | NONE |
| - | - | - | - |
| 5z1 | 1.0004x | 129.861 GiB | off |
| 5z1 | 1.0625x | 122.273 GiB | zstd-3 |
| 5z1 | 1.0316x | 125.923 GiB | zstd-fast |
| 5z1 | 1.0291x | 126.237 GiB | lz4 |
| - | - | - | - |
| 7z1 | 1.0126x | 128.294 GiB | off |
| 7z1 | 1.0758x | 120.752 GiB | zstd-3 |
| 7z1 | 1.0443x | 124.392 GiB | zstd-fast |
| 7z1 | 1.0418x | 124.701 GiB | lz4 |
The datasets on 5z1 seem to retain similar sizes as in the earlier table, but the 7z1 datasets all grew in size, as if to use up the extra ~300GiB (the 4.96 to 5.23 reporting change)? So…I’m not really sure I’m getting as much of a benefit as the “15GiB” savings from earlier would indicate. Does anyone have any insight about this? Does using 5 or 6 data disks as opposed to 4 (multiple of 2) in raidz1 just result in this behaviour/is it something I should avoid for reasons other than failure scenarios?
Something to note is that, even with wildly differing reporting sizes, the compression ratios are still pretty much the same compared to their supposed uncompressed sizes in each configuration, which is something I guess I would expect.
| array | ratio |
du -s size |
algorithm |
|---|---|---|---|
| 6z1 | 1.0000x | 125.043 GiB | off |
| 6z1 | 1.0524x | 118.814 GiB | zstd-1 |
| 6z1 | 1.0566x | 118.344 GiB | zstd-2 |
| 6z1 | 1.0615x | 117.791 GiB | zstd-3 |
| 6z1 | 1.0655x | 117.346 GiB | zstd-5 |
| 6z1 | 1.0662x | 117.272 GiB | zstd-10 |
| 6z1 | 1.0694x | 116.920 GiB | zstd-19 |
| 6z1 | 1.0310x | 121.274 GiB | zstd-fast |
| 6z1 | 1.0285x | 121.576 GiB | lz4 |
| - | - | - | - |
| 5z1 | 1.0000x | 129.911 GiB | off |
| 5z1 | 1.0612x | 122.410 GiB | zstd-3 |
| 5z1 | 1.0310x | 126.004 GiB | zstd-fast |
| 5z1 | 1.0284x | 126.317 GiB | lz4 |
| - | - | - | - |
| 7z1 | 1.0000x | 121.799 GiB | off |
| 7z1 | 1.0616x | 114.730 GiB | zstd-3 |
| 7z1 | 1.0695x | 113.881 GiB | zstd-19 |
| 7z1 | 1.0310x | 118.127 GiB | zstd-fast |
| 7z1 | 1.0285x | 118.420 GiB | lz4 |
[0]: it’s actually compressed there, too, but du seems to report the actual, uncompressed size, according to the output I got from compsize. tbh I feel like this should be normal behaviour, but… (du --apparent-size does report the actual size in all the tested configurations, though)
