diff --git a/syncoid b/syncoid index 956f3e7..e908a6c 100755 --- a/syncoid +++ b/syncoid @@ -17,6 +17,9 @@ use Capture::Tiny ':all'; my $mbuffer_size = "16M"; my $pvoptions = "-p -t -e -r -b"; +# Get number of CPUs for zstd threading, but leave at least two cores empty for system responsiveness +my $ncpus = int(`nproc`); +if ($ncpus > 2) { $ncpus -= 2;} # Blank defaults to use ssh client's default # TODO: Merge into a single "sshflags" option? @@ -1141,10 +1144,16 @@ sub compressargset { decomargs => '-dc', }, 'zstd-fast' => { - rawcmd => 'zstd', - args => '-3', - decomrawcmd => 'zstd', - decomargs => '-dc', + rawcmd => 'zstd', + args => "-T$ncpus -3", + decomrawcmd => 'zstd', + decomargs => "-T$ncpus -dc", + }, + 'zstd-medium' => { + rawcmd => 'zstd', + args => "-T$ncpus -8", + decomrawcmd => 'zstd', + decomargs => "-T$ncpus -dc", }, 'zstdmt-fast' => { rawcmd => 'zstdmt', @@ -1153,10 +1162,10 @@ sub compressargset { decomargs => '-dc', }, 'zstd-slow' => { - rawcmd => 'zstd', - args => '-19', - decomrawcmd => 'zstd', - decomargs => '-dc', + rawcmd => 'zstd', + args => "-T$ncpus -19", + decomrawcmd => 'zstd', + decomargs => "-T$ncpus -dc", }, 'zstdmt-slow' => { rawcmd => 'zstdmt', @@ -1186,7 +1195,7 @@ sub compressargset { if ($value eq 'default') { $value = $DEFAULT_COMPRESSION; - } elsif (!(grep $value eq $_, ('gzip', 'pigz-fast', 'pigz-slow', 'zstd-fast', 'zstdmt-fast', 'zstd-slow', 'zstdmt-slow', 'lz4', 'xz', 'lzo', 'default', 'none'))) { + } elsif (!(grep $value eq $_, ('gzip', 'pigz-fast', 'pigz-slow', 'zstd-fast', 'zstd-medium', 'zstdmt-fast', 'zstd-slow', 'zstdmt-slow', 'lz4', 'xz', 'lzo', 'default', 'none'))) { writelog('WARN', "Unrecognised compression value $value, defaulting to $DEFAULT_COMPRESSION"); $value = $DEFAULT_COMPRESSION; } @@ -2400,7 +2409,7 @@ syncoid - ZFS snapshot replication tool Options: - --compress=FORMAT Compresses data during transfer. Currently accepted options are gzip, pigz-fast, pigz-slow, zstd-fast, zstdmt-fast, zstd-slow, zstdmt-slow, lz4, xz, lzo (default) & none + --compress=FORMAT Compresses data during transfer. Currently accepted options are gzip, pigz-fast, pigz-slow, zstd-fast, zstd-medium, zstdmt-fast, zstd-slow, zstdmt-slow, lz4, xz, lzo (default) & none --identifier=EXTRA Extra identifier which is included in the snapshot name. Can be used for replicating to multiple targets. --recursive|r Also transfers child datasets --skip-parent Skips syncing of the parent dataset. Does nothing without '--recursive' option.