chiark
/
gitweb
/
~ian
/
version-charset-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b71f045
)
check really parallel
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Fri, 4 Nov 2016 14:33:18 +0000
(14:33 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Fri, 4 Nov 2016 14:33:18 +0000
(14:33 +0000)
check
patch
|
blob
|
history
diff --git
a/check
b/check
index 72933711c3ad9a4a96e69b6722f89e212600c771..b9eac539ea58d4b50805dbf7e25d6f9b65cd97b1 100755
(executable)
--- a/
check
+++ b/
check
@@
-2,13
+2,30
@@
set -e
set -o pipefail
set -e
set -o pipefail
+cpus=$(
+ perl -we '
+ use strict;
+ require Sys::CPU;
+ my $ncpus = Sys::CPU::cpu_count();
+ $ncpus *= 1.5;
+ print join " ", (0 .. $ncpus-1) or die $!;
+ print "\n" or die $!;
+ ' ||
+ echo 0 1 2
+)
+
rm -rf stunt
mkdir stunt
cd stunt
rm -rf stunt
mkdir stunt
cd stunt
+for cpu in $cpus; do
+ mkdir c$cpu
+ (cd c$cpu
+ git init)
+done
+
#exec 3<&0 </dev/null
#exec 3<&0 </dev/null
-git init
#git commit --allow-empty -m 'Test object'
#head=`git rev-parse HEAD`
#git commit --allow-empty -m 'Test object'
#head=`git rev-parse HEAD`
@@
-22,20
+39,17
@@
perl -we '
our $batch=0;
our @tasks;
our $batch=0;
our @tasks;
- my $ncpus = eval {
- require Sys::CPU;
- Sys::CPU::cpu_count();
- } // 3;
+ my @freecpus = qw('"$cpus"');
-$ncpus=1;
- print STDERR "check using $ncpus cpus\n";
+ print STDERR "check using cpus @freecpus\n";
sub await_task () {
sub await_task () {
- my ($pid, $oldbatch) = @{ shift @tasks };
+ my ($pid, $
cpu, $
oldbatch) = @{ shift @tasks };
waitpid $pid, 0 == $pid or die $!;
die "$oldbatch $?" if $?;
waitpid $pid, 0 == $pid or die $!;
die "$oldbatch $?" if $?;
- unlink $oldbatch or die "$oldbatch $!";
- print STDERR "check completed $oldbatch [$pid]\n";
+ unlink "b$oldbatch" or die "$oldbatch $!";
+ print STDERR "check completed $oldbatch [$pid] #$cpu\n";
+ push @freecpus, $cpu;
}
sub complete_batch () {
}
sub complete_batch () {
@@
-45,19
+59,22
@@
$ncpus=1;
print STDERR "check closing $batch ($count)\n";
print STDERR "check closing $batch ($count)\n";
- await_task if @tasks >= $ncpus;
+ await_task unless @freecpus;
+
+ my $cpu = shift @freecpus;
my $pid = fork // die $!;
if (!$pid) {
close STDIN;
# seek STDIN,0,1;
# flush STDIN;
my $pid = fork // die $!;
if (!$pid) {
close STDIN;
# seek STDIN,0,1;
# flush STDIN;
- open STDIN, "<", $batch or die $batch;
- exec qw(git update-ref --stdin);
+ open STDIN, "<", "b$batch" or die $batch;
+ chdir "c$cpu" or die "$cpu $!";
+ exec qw(eatmydata git update-ref --stdin);
die $!;
}
die $!;
}
- print STDERR "check spawned $batch ($count) [$pid]\n";
- push @tasks, [ $pid, $batch ];
+ print STDERR "check spawned $batch ($count) [$pid]
#$cpu
\n";
+ push @tasks, [ $pid, $
cpu, $
batch ];
$batch++;
$file = undef;
$count = 0;
$batch++;
$file = undef;
$count = 0;
@@
-65,7
+82,7
@@
$ncpus=1;
while (<>) {
#print STDERR ">$_<\n";
while (<>) {
#print STDERR ">$_<\n";
- $file ||= new IO::File
$batch
, ">" or die $!;
+ $file ||= new IO::File
"b$batch"
, ">" or die $!;
chomp;
print $file "delete refs/tags/$_\n" or die $!;
$count++ < 100000 or complete_batch;
chomp;
print $file "delete refs/tags/$_\n" or die $!;
$count++ < 100000 or complete_batch;