mirror of
https://github.com/NixOS/nix.git
synced 2024-11-01 23:00:55 +00:00
* Re-use prepared statements across insertions into the manifest cache
DB. This speeds up creating the cache from 16.1s to 7.9s on my system.
This commit is contained in:
parent
c0b706213d
commit
a5952405d2
@ -286,6 +286,14 @@ EOF
|
|||||||
open MAINLOCK, ">>$lockFile" or die "unable to acquire lock ‘$lockFile’: $!\n";
|
open MAINLOCK, ">>$lockFile" or die "unable to acquire lock ‘$lockFile’: $!\n";
|
||||||
flock(MAINLOCK, LOCK_EX) or die;
|
flock(MAINLOCK, LOCK_EX) or die;
|
||||||
|
|
||||||
|
our $insertNAR = $dbh->prepare(
|
||||||
|
"insert into NARs(manifest, storePath, url, hash, size, narHash, " .
|
||||||
|
"narSize, refs, deriver, system) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") or die;
|
||||||
|
|
||||||
|
our $insertPatch = $dbh->prepare(
|
||||||
|
"insert into Patches(manifest, storePath, basePath, baseHash, url, hash, " .
|
||||||
|
"size, narHash, narSize, patchType) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
$dbh->begin_work;
|
$dbh->begin_work;
|
||||||
|
|
||||||
# Read each manifest in $manifestDir and add it to the database,
|
# Read each manifest in $manifestDir and add it to the database,
|
||||||
@ -312,20 +320,16 @@ EOF
|
|||||||
|
|
||||||
sub addNARToDB {
|
sub addNARToDB {
|
||||||
my ($storePath, $narFile) = @_;
|
my ($storePath, $narFile) = @_;
|
||||||
$dbh->do(
|
$insertNAR->execute(
|
||||||
"insert into NARs(manifest, storePath, url, hash, size, narHash, " .
|
$id, $storePath, $narFile->{url}, $narFile->{hash}, $narFile->{size},
|
||||||
"narSize, refs, deriver, system) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
||||||
{}, $id, $storePath, $narFile->{url}, $narFile->{hash}, $narFile->{size},
|
|
||||||
$narFile->{narHash}, $narFile->{narSize}, $narFile->{references},
|
$narFile->{narHash}, $narFile->{narSize}, $narFile->{references},
|
||||||
$narFile->{deriver}, $narFile->{system});
|
$narFile->{deriver}, $narFile->{system});
|
||||||
};
|
};
|
||||||
|
|
||||||
sub addPatchToDB {
|
sub addPatchToDB {
|
||||||
my ($storePath, $patch) = @_;
|
my ($storePath, $patch) = @_;
|
||||||
$dbh->do(
|
$insertPatch->execute(
|
||||||
"insert into Patches(manifest, storePath, basePath, baseHash, url, hash, " .
|
$id, $storePath, $patch->{basePath}, $patch->{baseHash}, $patch->{url},
|
||||||
"size, narHash, narSize, patchType) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
||||||
{}, $id, $storePath, $patch->{basePath}, $patch->{baseHash}, $patch->{url},
|
|
||||||
$patch->{hash}, $patch->{size}, $patch->{narHash}, $patch->{narSize},
|
$patch->{hash}, $patch->{size}, $patch->{narHash}, $patch->{narSize},
|
||||||
$patch->{patchType});
|
$patch->{patchType});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user