diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-12-21 18:59:25 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-12-21 18:59:25 +0000 |
commit | 69d6f0936a59da5cc35040407f4b667437d61add (patch) | |
tree | 359468ac775b4f2851a806f7e00d1838bd5c5650 /scripts/build-remote.pl.in | |
parent | 38776198880d06dc6af0fbdfa7cb2c053000112a (diff) |
* Use a lock to ensure that only one build-remote instance can copy a
closure to a given machine at the same time. This prevents the case
where multiple instances try to copy the same missing store path to
the target machine, which is very wasteful.
Diffstat (limited to 'scripts/build-remote.pl.in')
-rwxr-xr-x | scripts/build-remote.pl.in | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in index c805d6740..6a6515756 100755 --- a/scripts/build-remote.pl.in +++ b/scripts/build-remote.pl.in @@ -225,8 +225,17 @@ sub removeRoots { } -# Copy the derivation and its dependencies to the build machine. +# Copy the derivation and its dependencies to the build machine. This +# is guarded by an exclusive lock per machine to prevent multiple +# build-remote instances from copying to a machine simultaneously. +# That's undesirable because we may end up with N instances uploading +# the same missing path simultaneously, causing the effective network +# bandwidth and target disk speed to be divided by N. +my $uploadLock = "$currentLoad/$hostName.upload-lock"; +open MAINLOCK, ">>$uploadLock" or die; +flock(MAINLOCK, LOCK_EX) or die; Nix::CopyClosure::copyTo($hostName, [ @sshOpts ], [ $drvPath, @inputs ], "", "", 0, 0, $maybeSign ne ""); +close MAINLOCK; # Perform the build. |