Time for some surprising/disappointing results.
Synthetic benchmarks
borg benchmark crud
First column: [C]reate, [R]ead, [U]pdate, [D]elete
Second column: [Z]ero file, [R]andom file
C-Z-BIG 212.70 MB/s (10 * 100.00 MB all-zero files: 4.70s)
R-Z-BIG 320.26 MB/s (10 * 100.00 MB all-zero files: 3.12s)
U-Z-BIG 1608.99 MB/s (10 * 100.00 MB all-zero files: 0.62s)
D-Z-BIG 2893.47 MB/s (10 * 100.00 MB all-zero files: 0.35s)
C-R-BIG 115.99 MB/s (10 * 100.00 MB random files: 8.62s)
R-R-BIG 184.58 MB/s (10 * 100.00 MB random files: 5.42s)
U-R-BIG 1902.28 MB/s (10 * 100.00 MB random files: 0.53s)
D-R-BIG 365.61 MB/s (10 * 100.00 MB random files: 2.74s)
C-Z-MEDIUM 150.24 MB/s (1000 * 1.00 MB all-zero files: 6.66s)
R-Z-MEDIUM 380.77 MB/s (1000 * 1.00 MB all-zero files: 2.63s)
U-Z-MEDIUM 4389.63 MB/s (1000 * 1.00 MB all-zero files: 0.23s)
D-Z-MEDIUM 9237.31 MB/s (1000 * 1.00 MB all-zero files: 0.11s)
C-R-MEDIUM 108.29 MB/s (1000 * 1.00 MB random files: 9.23s)
R-R-MEDIUM 153.02 MB/s (1000 * 1.00 MB random files: 6.53s)
U-R-MEDIUM 4613.61 MB/s (1000 * 1.00 MB random files: 0.22s)
D-R-MEDIUM 288.00 MB/s (1000 * 1.00 MB random files: 3.47s)
C-Z-SMALL 33.25 MB/s (10000 * 10.00 kB all-zero files: 3.01s)
R-Z-SMALL 153.04 MB/s (10000 * 10.00 kB all-zero files: 0.65s)
U-Z-SMALL 84.67 MB/s (10000 * 10.00 kB all-zero files: 1.18s)
D-Z-SMALL 515.81 MB/s (10000 * 10.00 kB all-zero files: 0.19s)
C-R-SMALL 23.46 MB/s (10000 * 10.00 kB random files: 4.26s)
R-R-SMALL 144.29 MB/s (10000 * 10.00 kB random files: 0.69s)
U-R-SMALL 59.00 MB/s (10000 * 10.00 kB random files: 1.69s)
D-R-SMALL 142.62 MB/s (10000 * 10.00 kB random files: 0.70s)
This benchmark was done on the local SSD, so there is no bottleneck from a USB/network interface or HDD. The C-R-BIG result of 115 MB/s seems like the “better” case scenario. Zero files get totally deduplicated, so not meaningful here. For small random files it’s much slower at only ~20 MB/s.
So it would appear that USB/HDD won’t be much of a bottleneck after all.
Real data benchmarks
I also tested compression ratio and throughput with a script using my own data. It varies a lot depending on the data. Again all on the local SSD.
Backing up a ~35 MB directory of mostly documents (openoffice, pdf):
algorithm |
compression ratio |
rate [MB/s] |
none |
0.99 |
80.60 |
lz4 |
1.13 |
68.96 |
zstd,1 |
1.16 |
62.90 |
zstd,3 |
1.19 |
56.88 |
zstd,6 |
1.20 |
39.99 |
zstd,9 |
1.20 |
37.24 |
lzma |
1.21 |
4.76 |
Backing up /etc
:
algorithm |
compression ratio |
rate [MB/s] |
none |
0.99 |
28.17 |
lz4 |
2.72 |
10.21 |
zstd,1 |
4.09 |
6.54 |
zstd,3 |
4.31 |
6.09 |
zstd,6 |
4.49 |
5.10 |
zstd,9 |
4.67 |
4.02 |
lzma |
5.41 |
0.50 |
lzma really doesn’t seem worth it because it gets only a bit more compression than zstd, but is 10X slower. Maybe a low level zstd is more favorable than lz4, or maybe not. The drop in rate is usually slightly more than the gain through increased compression. In the end, it doesn’t seem particularly compelling either way.
All this time I thought “slow” HDDs would be the bottleneck. Looks like the bottleneck is borg! I wonder how much it could improve with multi-threading/parallelization.
Other factors which also have an impact
- The rates do drop further when backing up to a slower/older external HDD over USB3. I didn’t test my new backup drive yet as
badblocks
is still working on it.
- Encrypted (repokey-blake2) repositories drop the rate slightly as well. It’s not a lot, and it’s also not too realistic to use no encryption, so I don’t worry about this much.
- Slower computers also show slower rates. The above benchmarks were done on a Ryzen 7 2700X. On an i5-5300U the real data benchmark rates were ~75% of the above results.
Tentative conclusion
I’m tempted to go with zstd, just out of curiosity for a new fancy algorithm. Maybe level 3, which happens to be borg’s default setting for zstd. The Density compression algorithm mentioned above is also interesting, but I definitely don’t want to complicate my life with borg. The closer to defaults, the better.