Skip to content

Commit

Permalink
Smartify harness automatic job number calculation
Browse files Browse the repository at this point in the history
- Use TEST_JOBS if we were given any
- Instead of using default 6 jobs, calculate using the number of CPUs
    on the box. Multiplying number by 1.3 is the optimal number of
    test jobs I found a while back.
- On harness6 old default was 1 by mistake; it was supposed to be 6
- Default to 6 cores if our cpu-core computation fails for some reason
  • Loading branch information
zoffixznet committed Dec 31, 2017
1 parent 0444a2c commit 6f36b02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions t/harness5
Expand Up @@ -24,7 +24,7 @@ GetOptions(
'tests-from-file=s' => \my $list_file,
'fudge' => \my $do_fudge,
'verbosity=i' => \$Test::Harness::verbose,
'jobs:1' => \(my $jobs = $ENV{TEST_JOBS} || 6),
'jobs=i' => \my $jobs,
'quick:1' => \my $do_quick,
'stress:1' => \my $do_stress,
'archive=s' => \my $archive,
Expand All @@ -39,8 +39,13 @@ GetOptions(
my @pass_through_options = grep m/^--?[^-]/, @ARGV;
my @files = grep m/^[^-]/, @ARGV;

$ENV{'HARNESS_PERL'} = ".${slash}perl6-" . ($moar ? "m" : $jvm ? "j" : "m");
$ENV{'PERL6LIB'} = "lib";
$ENV{HARNESS_PERL} = ".${slash}perl6-" . ($moar ? "m" : $jvm ? "j" : "m");
$ENV{PERL6LIB} = "lib";

$jobs ||= $ENV{TEST_JOBS}
|| sprintf("%d", 1.3 * qx/$ENV{HARNESS_PERL} -e Kernel.cpu-cores.print/)
|| 6;
print "Using $jobs test jobs\n";

my @slow;
if ($list_file) {
Expand Down
3 changes: 2 additions & 1 deletion t/harness6
Expand Up @@ -29,7 +29,7 @@ sub MAIN(
Str :$tests-from-file is copy = Str,
Bool :$fudge = False,
Int :$verbosity = (%*ENV<TEST_VERBOSE> // 0).Int,
Int :$jobs = (%*ENV<TEST_JOBS> // 1).Int,
Int :$jobs = (%*ENV<TEST_JOBS> || Int(1.3 * Kernel.cpu-cores) || 6).Int,
Bool :$quick = False,
Bool :$stress = False,
Bool :$randomize = False,
Expand All @@ -38,6 +38,7 @@ sub MAIN(
Str :$perl5path = 'perl',
*@files,
) {
say "Using $jobs test jobs";
my @slow;
with $tests-from-file {
$tests-from-file .= &convert-to-versioned-file;
Expand Down

0 comments on commit 6f36b02

Please sign in to comment.