Store::computeFSClosure(): Support a set of paths
This way, callers can exploits the parallelism of computeFSClosure() when they have multiple paths that they need the (combined) closure of.
This commit is contained in:
parent
2af5d35fdc
commit
dd77f7d593
5 changed files with 25 additions and 16 deletions
|
@ -1249,8 +1249,7 @@ void DerivationGoal::inputsRealised()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second, the input sources. */
|
/* Second, the input sources. */
|
||||||
for (auto & i : drv->inputSrcs)
|
worker.store.computeFSClosure(drv->inputSrcs, inputPaths);
|
||||||
worker.store.computeFSClosure(i, inputPaths);
|
|
||||||
|
|
||||||
debug(format("added input paths %1%") % showPaths(inputPaths));
|
debug(format("added input paths %1%") % showPaths(inputPaths));
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
void Store::computeFSClosure(const Path & startPath,
|
void Store::computeFSClosure(const PathSet & startPaths,
|
||||||
PathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
PathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
||||||
{
|
{
|
||||||
struct State
|
struct State
|
||||||
|
@ -85,6 +85,7 @@ void Store::computeFSClosure(const Path & startPath,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for (auto & startPath : startPaths)
|
||||||
enqueue(startPath);
|
enqueue(startPath);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -95,6 +96,13 @@ void Store::computeFSClosure(const Path & startPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Store::computeFSClosure(const Path & startPath,
|
||||||
|
PathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
||||||
|
{
|
||||||
|
computeFSClosure(PathSet{startPath}, paths_, flipDirection, includeOutputs, includeDerivers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Store::queryMissing(const PathSet & targets,
|
void Store::queryMissing(const PathSet & targets,
|
||||||
PathSet & willBuild_, PathSet & willSubstitute_, PathSet & unknown_,
|
PathSet & willBuild_, PathSet & willSubstitute_, PathSet & unknown_,
|
||||||
unsigned long long & downloadSize_, unsigned long long & narSize_)
|
unsigned long long & downloadSize_, unsigned long long & narSize_)
|
||||||
|
|
|
@ -477,15 +477,19 @@ public:
|
||||||
ensurePath(). */
|
ensurePath(). */
|
||||||
Derivation derivationFromPath(const Path & drvPath);
|
Derivation derivationFromPath(const Path & drvPath);
|
||||||
|
|
||||||
/* Place in `paths' the set of all store paths in the file system
|
/* Place in `out' the set of all store paths in the file system
|
||||||
closure of `storePath'; that is, all paths than can be directly
|
closure of `storePath'; that is, all paths than can be directly
|
||||||
or indirectly reached from it. `paths' is not cleared. If
|
or indirectly reached from it. `out' is not cleared. If
|
||||||
`flipDirection' is true, the set of paths that can reach
|
`flipDirection' is true, the set of paths that can reach
|
||||||
`storePath' is returned; that is, the closures under the
|
`storePath' is returned; that is, the closures under the
|
||||||
`referrers' relation instead of the `references' relation is
|
`referrers' relation instead of the `references' relation is
|
||||||
returned. */
|
returned. */
|
||||||
|
void computeFSClosure(const PathSet & paths,
|
||||||
|
PathSet & out, bool flipDirection = false,
|
||||||
|
bool includeOutputs = false, bool includeDerivers = false);
|
||||||
|
|
||||||
void computeFSClosure(const Path & path,
|
void computeFSClosure(const Path & path,
|
||||||
PathSet & paths, bool flipDirection = false,
|
PathSet & out, bool flipDirection = false,
|
||||||
bool includeOutputs = false, bool includeDerivers = false);
|
bool includeOutputs = false, bool includeDerivers = false);
|
||||||
|
|
||||||
/* Given a set of paths that are to be built, return the set of
|
/* Given a set of paths that are to be built, return the set of
|
||||||
|
|
|
@ -424,10 +424,9 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
case qRoots: {
|
case qRoots: {
|
||||||
PathSet referrers;
|
PathSet referrers;
|
||||||
for (auto & i : opArgs) {
|
for (auto & i : opArgs) {
|
||||||
PathSet paths = maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise);
|
store->computeFSClosure(
|
||||||
for (auto & j : paths)
|
maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise),
|
||||||
store->computeFSClosure(j, referrers, true,
|
referrers, true, settings.gcKeepOutputs, settings.gcKeepDerivations);
|
||||||
settings.gcKeepOutputs, settings.gcKeepDerivations);
|
|
||||||
}
|
}
|
||||||
Roots roots = store->findRoots();
|
Roots roots = store->findRoots();
|
||||||
for (auto & i : roots)
|
for (auto & i : roots)
|
||||||
|
@ -961,10 +960,9 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
case cmdQueryClosure: {
|
case cmdQueryClosure: {
|
||||||
bool includeOutputs = readInt(in);
|
bool includeOutputs = readInt(in);
|
||||||
PathSet paths = readStorePaths<PathSet>(*store, in);
|
|
||||||
PathSet closure;
|
PathSet closure;
|
||||||
for (auto & i : paths)
|
store->computeFSClosure(readStorePaths<PathSet>(*store, in),
|
||||||
store->computeFSClosure(i, closure, false, includeOutputs);
|
closure, false, includeOutputs);
|
||||||
out << closure;
|
out << closure;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,8 @@ void StorePathsCommand::run(ref<Store> store)
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
PathSet closure;
|
PathSet closure;
|
||||||
for (auto & storePath : storePaths)
|
store->computeFSClosure(PathSet(storePaths.begin(), storePaths.end()),
|
||||||
store->computeFSClosure(storePath, closure, false, false);
|
closure, false, false);
|
||||||
storePaths = Paths(closure.begin(), closure.end());
|
storePaths = Paths(closure.begin(), closure.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue