Call queryMissing() prior to building

Without this, substitute info is fetched sequentially, which is
superslow. In the old UI (e.g. nix-build), we call printMissing(),
which calls queryMissing(), thereby preheating the binary cache
cache. But the new UI doesn't do that.
This commit is contained in:
Eelco Dolstra 2017-08-31 16:02:36 +02:00
parent fd73c1e20a
commit bbdf08bc0f
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 14 additions and 0 deletions

View file

@ -4166,10 +4166,20 @@ void Worker::markContentsGood(const Path & path)
//////////////////////////////////////////////////////////////////////
static void primeCache(Store & store, const PathSet & paths)
{
PathSet willBuild, willSubstitute, unknown;
unsigned long long downloadSize, narSize;
store.queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize, narSize);
}
void LocalStore::buildPaths(const PathSet & drvPaths, BuildMode buildMode)
{
Worker worker(*this);
primeCache(*this, drvPaths);
Goals goals;
for (auto & i : drvPaths) {
DrvPathWithOutputs i2 = parseDrvPathWithOutputs(i);
@ -4220,6 +4230,8 @@ void LocalStore::ensurePath(const Path & path)
/* If the path is already valid, we're done. */
if (isValidPath(path)) return;
primeCache(*this, {path});
Worker worker(*this);
GoalPtr goal = worker.makeSubstitutionGoal(path);
Goals goals = {goal};

View file

@ -107,6 +107,8 @@ void Store::queryMissing(const PathSet & targets,
PathSet & willBuild_, PathSet & willSubstitute_, PathSet & unknown_,
unsigned long long & downloadSize_, unsigned long long & narSize_)
{
Activity act(*logger, lvlDebug, actUnknown, "querying info about missing paths");
downloadSize_ = narSize_ = 0;
ThreadPool pool;