forked from lix-project/lix
* 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.
This commit is contained in:
parent
3877619888
commit
69d6f0936a
|
@ -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 "");
|
Nix::CopyClosure::copyTo($hostName, [ @sshOpts ], [ $drvPath, @inputs ], "", "", 0, 0, $maybeSign ne "");
|
||||||
|
close MAINLOCK;
|
||||||
|
|
||||||
|
|
||||||
# Perform the build.
|
# Perform the build.
|
||||||
|
|
Loading…
Reference in a new issue