about summary refs log tree commit diff
path: root/distributed
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-05-13T19·35+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-05-13T19·35+0000
commit25db6224544be0df483a661f5e2cc1ed595525ae (patch)
treedd497e6148b88ec797c01d2e1310a663e86281fb /distributed
parent3426d19547c889700a00e97fb62966ebd755f88b (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')
-rwxr-xr-xdistributed/build-remote.pl36
-rw-r--r--distributed/remote-systems.conf2
-rwxr-xr-xdistributed/test.sh5
3 files changed, 33 insertions, 10 deletions
diff --git a/distributed/build-remote.pl b/distributed/build-remote.pl
index f1a9b10f4d60..12cb272b95fa 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
diff --git a/distributed/remote-systems.conf b/distributed/remote-systems.conf
index 4e6d2b962d80..3c9abc7194b4 100644
--- a/distributed/remote-systems.conf
+++ b/distributed/remote-systems.conf
@@ -1,2 +1,2 @@
-scratchy.labs.cs.uu.nl   i686-linux     /home/eelco/.ssh/id_scratchy_auto       2
+scratchy.labs.cs.uu.nl   i686-linux     /home/eelco/.ssh/id_scratchy_auto       1
 mckroket.labs.cs.uu.nl   powerpc-mac    /home/eelco/.ssh/id_scratchy_mckroket   1
diff --git a/distributed/test.sh b/distributed/test.sh
index 38116eba5dd1..78f83095e820 100755
--- a/distributed/test.sh
+++ b/distributed/test.sh
@@ -2,8 +2,11 @@
 
 set -e
 
+rm -f current-load
+touch current-load
+
 storeExpr=$(nix-instantiate ~/nixpkgs/pkgs/system/test.nix)
 
 export NIX_BUILD_HOOK="build-remote.pl"
 
-../src/nix-store/nix-store -qnvvvv -j0 $storeExpr
+../src/nix-store/nix-store -qnvvvv -j1 $storeExpr