* Add a NarSize field to Hydra manifests. This allows nix-env

to predict how much disk space a package will require.
* Compute the output / closure size using the info stored in the
  Nix database (rather than doing a slow "du").
This commit is contained in:
Eelco Dolstra 2010-11-19 15:44:20 +00:00
parent ba31684153
commit a93e272364
4 changed files with 17 additions and 24 deletions

View file

@ -8,8 +8,8 @@ let
name = "Nix-0.15";
src = fetchsvn {
url = https://svn.nixos.org/repos/nix/nix-perl/trunk;
rev = 24765;
sha256 = "12ah8c8p9bx55hd17lhcfc74bd4r1677dxy0id3008pww1aklir7";
rev = 24774;
sha256 = "1akj695gpnbrjlnwd1gdnnnk7ppvpp1qsinjn04az7q6hjqzbm6p";
};
NIX_PREFIX = nixSqlite;
doCheck = false; # tests currently don't work

View file

@ -9,7 +9,7 @@ use Hydra::Helper::CatalystUtils;
our @ISA = qw(Exporter);
our @EXPORT = qw(
isValidPath queryPathInfo
isValidPath
getHydraPath getHydraDBPath openHydraDB txn_do
registerRoot getGCRootsDir gcRootFor
getPrimaryBuildsForView
@ -23,17 +23,6 @@ sub isValidPath {
}
sub queryPathInfo {
my $path = shift;
my $hash = Nix::queryPathHash($path);
my $deriver = Nix::queryDeriver($path);
my @refs = Nix::queryReferences($path);
return ($hash, $deriver, \@refs);
}
sub getHydraPath {
my $dir = $ENV{"HYDRA_DATA"};
die "The HYDRA_DATA environment variable is not set!\n" unless defined $dir;

View file

@ -21,7 +21,7 @@ sub process {
"}\n";
foreach my $path (@paths) {
my ($hash, $deriver, $refs) = queryPathInfo $path;
my ($deriver, $hash, $time, $narSize, $refs) = Nix::queryPathInfo $path;
# Escape the characters that are allowed to appear in a Nix
# path name but have special meaning in a URI.
@ -40,6 +40,7 @@ sub process {
(defined $deriver ? " Deriver: $deriver\n" : "") .
" NarURL: $url\n" .
" NarHash: $hash\n" .
($narSize != 0 ? " NarSize: $narSize\n" : "") .
"}\n";
}

View file

@ -199,10 +199,6 @@ sub sendEmailNotification {
sendmail($email);
}
sub getSize {
my $size = `du -bcs @_ 2> /dev/null | tail -1 | cut -f 1 `;
return int($size);
}
sub doBuild {
my ($build) = @_;
@ -233,7 +229,7 @@ sub doBuild {
# Run Nix to perform the build, and monitor the stderr output
# to get notifications about specific build steps, the
# associated log files, etc.
my $cmd = "nix-store --realise $drvPath " .
my $cmd = "nix-store -j1 --no-build-hook --realise $drvPath " .
"--max-silent-time $maxsilent --keep-going --fallback " .
"--no-build-output --log-type flat --print-build-trace " .
"--add-root " . gcRootFor $outPath . " 2>&1";
@ -371,13 +367,20 @@ sub doBuild {
done:
my $logfile = getBuildLog($drvPath);
my $logsize = defined $logfile ? getSize($logfile) : 0;
my $size = isValidPath($outPath) ? getSize($outPath) : 0;
my $logsize = defined $logfile ? stat($logfile)->size : 0;
my $size = 0;
my $closuresize = 0;
if (isValidPath($outPath)) {
(my $hash, my $deriver, my $refs) = queryPathInfo($outPath) ;
$closuresize = getSize(@{$refs});
my ($deriver, $hash, $time, $narSize, $refs) = Nix::queryPathInfo($outPath);
$size = $narSize;
my @closure = Nix::computeFSClosure(0, 0, $outPath);
foreach my $path (@closure) {
my ($deriver, $hash, $time, $narSize, $refs) = Nix::queryPathInfo($path);
$closuresize += $narSize;
}
}
txn_do($db, sub {