Merge pull request #86 from rlanyi/extractstats-multithread

Add THREADS env var to control number of threads
This commit is contained in:
Manuel Kasper 2020-03-22 16:58:47 +01:00 committed by GitHub
commit 6cc32ebaa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,8 +42,12 @@ my @rrdfiles = File::Find::Rule->maxdepth(2)->file->in($rrdpath);
$|=1; $|=1;
my $i :shared = 0; my $i :shared = 0;
my $cpus = do { local @ARGV='/proc/cpuinfo'; grep /^processor\s+:/, <>;}; my $num_workers = 1;
my $num_workers = $cpus / 2; if (($ENV{'THREADS'}) and ($ENV{'THREADS'} =~ /^\d+$/) and ($ENV{'THREADS'} > 0)) {
$num_workers = $ENV{'THREADS'};
}
print("Using " . $num_workers . " threads.\n");
my $num_work_units = scalar @rrdfiles; my $num_work_units = scalar @rrdfiles;
my $q = Thread::Queue->new(); my $q = Thread::Queue->new();