+ if ( -r '/proc/cpuinfo') {
+ my $jobs = 0;
+ my $cpus = 0;
+ open my $fd, '<', '/proc/cpuinfo'
+ or fail ("failed to open /proc/cpuinfo: $!");
+ while (<$fd>) {
+ next unless m/^cpu cores\s*:\s*(\d+)/;
+ $jobs += $1;
+ $cpus++;
+ }
+ close $fd;
+
+ if ($cpus) {
+ # Running up to twice the number of cores usually gets the most out
+ # of the CPUs and disks but it might be too aggresive to be the
+ # default for -j. Only use <cores>+1 then.
+ debug_msg (1, "Number of cores: $jobs (CPUs: $cpus)");
+
+ return $jobs + 1;
+ }
+ debug_msg (1, "Did not find any core information for any cpus in /proc/cpuinfo?");
+ }
+
+ # No decent number of jobs? Just use 2 as a default
+ return 2;
+}