diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-05-13 19:35:46 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-05-13 19:35:46 +0000 |
commit | 25db6224544be0df483a661f5e2cc1ed595525ae (patch) | |
tree | dd497e6148b88ec797c01d2e1310a663e86281fb /distributed/build-remote.pl | |
parent | 3426d19547c889700a00e97fb62966ebd755f88b (diff) |
* Load balancing. `build-remote.pl' will only execute up to a
per-machine maximum number of parallel jobs on a remote machine.
Diffstat (limited to 'distributed/build-remote.pl')
-rwxr-xr-x | distributed/build-remote.pl | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/distributed/build-remote.pl b/distributed/build-remote.pl index f1a9b10f4..12cb272b9 100755 --- a/distributed/build-remote.pl +++ b/distributed/build-remote.pl @@ -7,9 +7,16 @@ my $localSystem = shift @ARGV; my $neededSystem = shift @ARGV; my $storeExpr = shift @ARGV; +sub sendReply { + my $reply = shift; + open OUT, ">&3" or die; + print OUT "$reply\n"; + close OUT; +} + # Decline if the local system can do the build. if ($amWilling && ($localSystem eq $neededSystem)) { - print "decline\n"; + sendReply "decline"; exit 0; } @@ -45,11 +52,8 @@ while (<LOAD>) { } close LOAD; -sub sendReply { - my $reply = shift; - open OUT, ">&3" or die; - print OUT "$reply\n"; - close OUT; +foreach my $cur (keys %machines) { + $curJobs{$cur} = 0 unless defined $curJobs{$cur}; } # Find a suitable system. @@ -58,8 +62,7 @@ my $machine; foreach my $cur (keys %machines) { if ($neededSystem eq $systemTypes{$cur}) { $rightType = 1; - if (!defined $curJobs{$cur} or - ($curJobs{$cur} < $maxJobs{$cur})) + if ($curJobs{$cur} < $maxJobs{$cur}) { $machine = $cur; last; @@ -86,6 +89,19 @@ close IN; print "BUILDING REMOTE: $storeExpr on $machine\n"; +$curJobs{$machine} = $curJobs{$machine} + 1; + +sub writeLoad { + open LOAD, "> /home/eelco/nix/distributed/current-load" or die; + foreach my $cur (keys %machines) { + print LOAD "$cur $curJobs{$cur}\n"; + } + close LOAD; +} + +writeLoad + + my $ssh = "ssh -i $sshKeys{$machine} -x"; my $inputs = `cat inputs`; @@ -117,3 +133,7 @@ foreach my $output (split '\n', $outputs) { system "rsync -a -e '$ssh' $machine:$output /nix/store"; die "cannot rsync outputs from $machine" if ($? != 0); } + +$curJobs{$machine} = $curJobs{$machine} - 1; + +writeLoad |