mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-13 21:24:01 +00:00
vzdump/pigz: use ProcFSTools for core count, not sysconf
A "sysconf(84)" is not really descripitve. There is no POSIX const entry for _SC_NPROCESSORS_ONLN (number of processors online) as its not standard but an adoption of glibc. Better just use our proven ProcFSTool's cpuinfo method for getting the desired information. This is kept only for backwards compatibillity as we guaranteed that we use #cpus/2 if 'pigz' is set to 1, else I would have removed this alltogether and just directly passed 'pigz' to the command... Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1c62fde24d
commit
8555b100bb
@ -727,9 +727,11 @@ sub compressor_info {
|
||||
return ('lzop', 'lzo');
|
||||
} elsif ($opt_compress eq 'gzip') {
|
||||
if ($opts->{pigz} > 0) {
|
||||
# As default use int((#cores + 1)/2), we need #cores+1 for the case that #cores = 1
|
||||
my $cores = POSIX::sysconf(84);
|
||||
my $pigz_threads = ($opts->{pigz} > 1) ? $opts->{pigz} : int(($cores + 1)/2);
|
||||
my $pigz_threads = $opts->{pigz};
|
||||
if ($pigz_threads == 1) {
|
||||
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
|
||||
$pigz_threads = int(($cpuinfo->{cpus} + 1)/2);
|
||||
}
|
||||
return ("pigz -p ${pigz_threads}", 'gz');
|
||||
} else {
|
||||
return ('gzip', 'gz');
|
||||
|
Loading…
Reference in New Issue
Block a user