summaryrefslogtreecommitdiff
path: root/Porting/bisect.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-04-10 10:37:41 +0200
committerNicholas Clark <nick@ccl4.org>2013-05-28 09:19:27 +0200
commit0bc550ba196833e65284f8977c95b37af2e7de00 (patch)
treed31e1df18ec414522d552f666c5fce86e13c1588 /Porting/bisect.pl
parentff9c1ae817f5e4013e88b98792d9dba6b0010a29 (diff)
downloadperl-0bc550ba196833e65284f8977c95b37af2e7de00.tar.gz
In bisect{,-runner}.pl, refactor the code for CPU probing and make jobs.
Move the code that attempts various ways to probe for the number of CPUs from bisect-runner.pl to bisect.pl. Skip the probe entirely if a -j (--jobs) options is passed to bisect.pl. For --jobs=0 (or -j0) entirely skip adding -j to the make command line. (For heretical versions of make which don't use -j for parallelism). Previously the probe code always ran for each call to bisect-runner.pl, which is completely redundant if bisect-runner.pl is being called for argument validation or help text, and inefficient even when building, as the number of CPUs rarely changes during a bisect run. Additionally there was no way to avoid a -j in the make command line, which isn't going to fly on systems where the make utility doesn't have a -j option.
Diffstat (limited to 'Porting/bisect.pl')
-rwxr-xr-xPorting/bisect.pl21
1 files changed, 19 insertions, 2 deletions
diff --git a/Porting/bisect.pl b/Porting/bisect.pl
index 29e3dedf04..7c0ba07eda 100755
--- a/Porting/bisect.pl
+++ b/Porting/bisect.pl
@@ -11,8 +11,8 @@ Documentation for this is in bisect-runner.pl
# Which isn't what we want.
use Getopt::Long qw(:config pass_through no_auto_abbrev);
-my ($start, $end, $validate, $usage, $bad);
-$bad = !GetOptions('start=s' => \$start, 'end=s' => \$end,
+my ($start, $end, $validate, $usage, $bad, $jobs);
+$bad = !GetOptions('start=s' => \$start, 'end=s' => \$end, 'jobs|j=i' => \$jobs,
validate => \$validate, 'usage|help|?' => \$usage);
unshift @ARGV, '--help' if $bad || $usage;
unshift @ARGV, '--validate' if $validate;
@@ -36,6 +36,23 @@ exit 0 if $usage;
my $start_time = time;
+if (!defined $jobs) {
+ # Try to default to (ab)use all the CPUs:
+ my $cpus;
+ if (open my $fh, '<', '/proc/cpuinfo') {
+ while (<$fh>) {
+ ++$cpus if /^processor\s+:\s+\d+$/;
+ }
+ } elsif (-x '/sbin/sysctl') {
+ $cpus = $1 if `/sbin/sysctl hw.ncpu` =~ /^hw\.ncpu: (\d+)$/;
+ } elsif (-x '/usr/bin/getconf') {
+ $cpus = $1 if `/usr/bin/getconf _NPROCESSORS_ONLN` =~ /^(\d+)$/;
+ }
+ $jobs = defined $cpus ? $cpus + 1 : 2;
+}
+
+unshift @ARGV, '--jobs', $jobs;
+
# We try these in this order for the start revision if none is specified.
my @stable = qw(perl-5.005 perl-5.6.0 perl-5.8.0 v5.10.0 v5.12.0 v5.14.0);