* Get derivation outputs from the database instead of the .drv file,
which requires more I/O.
This commit is contained in:
parent
103cfee056
commit
c4d388add4
7 changed files with 46 additions and 8 deletions
|
@ -467,10 +467,10 @@ bool LocalStore::tryToDelete(GCState & state, const Path & path)
|
||||||
then don't delete the derivation if any of the outputs are
|
then don't delete the derivation if any of the outputs are
|
||||||
live. */
|
live. */
|
||||||
if (state.gcKeepDerivations && isDerivation(path)) {
|
if (state.gcKeepDerivations && isDerivation(path)) {
|
||||||
Derivation drv = derivationFromPath(path);
|
PathSet outputs = queryDerivationOutputs(path);
|
||||||
foreach (DerivationOutputs::iterator, i, drv.outputs)
|
foreach (PathSet::iterator, i, outputs)
|
||||||
if (!tryToDelete(state, i->second.path)) {
|
if (!tryToDelete(state, *i)) {
|
||||||
printMsg(lvlDebug, format("cannot delete derivation `%1%' because its output is alive") % path);
|
printMsg(lvlDebug, format("cannot delete derivation `%1%' because its output `%2%' is alive") % path % *i);
|
||||||
goto isLive;
|
goto isLive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,6 +299,8 @@ void LocalStore::prepareStatements()
|
||||||
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
|
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
|
||||||
stmtQueryValidDerivers.create(db,
|
stmtQueryValidDerivers.create(db,
|
||||||
"select v.id, v.path from DerivationOutputs d join ValidPaths v on d.drv = v.id where d.path = ?;");
|
"select v.id, v.path from DerivationOutputs d join ValidPaths v on d.drv = v.id where d.path = ?;");
|
||||||
|
stmtQueryDerivationOutputs.create(db,
|
||||||
|
"select id, path from DerivationOutputs where drv = ?;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -623,6 +625,28 @@ PathSet LocalStore::queryValidDerivers(const Path & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PathSet LocalStore::queryDerivationOutputs(const Path & path)
|
||||||
|
{
|
||||||
|
SQLiteTxn txn(db);
|
||||||
|
|
||||||
|
SQLiteStmtUse use(stmtQueryDerivationOutputs);
|
||||||
|
stmtQueryDerivationOutputs.bind(queryPathInfo(path).id);
|
||||||
|
|
||||||
|
PathSet outputs;
|
||||||
|
int r;
|
||||||
|
while ((r = sqlite3_step(stmtQueryDerivationOutputs)) == SQLITE_ROW) {
|
||||||
|
const char * s = (const char *) sqlite3_column_text(stmtQueryDerivationOutputs, 1);
|
||||||
|
assert(s);
|
||||||
|
outputs.insert(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r != SQLITE_DONE)
|
||||||
|
throw SQLiteError(db, format("error getting outputs of `%1%'") % path);
|
||||||
|
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LocalStore::startSubstituter(const Path & substituter, RunningSubstituter & run)
|
void LocalStore::startSubstituter(const Path & substituter, RunningSubstituter & run)
|
||||||
{
|
{
|
||||||
if (run.pid != -1) return;
|
if (run.pid != -1) return;
|
||||||
|
|
|
@ -110,6 +110,8 @@ public:
|
||||||
not exist anymore.) */
|
not exist anymore.) */
|
||||||
PathSet queryValidDerivers(const Path & path);
|
PathSet queryValidDerivers(const Path & path);
|
||||||
|
|
||||||
|
PathSet queryDerivationOutputs(const Path & path);
|
||||||
|
|
||||||
PathSet querySubstitutablePaths();
|
PathSet querySubstitutablePaths();
|
||||||
|
|
||||||
bool hasSubstitutes(const Path & path);
|
bool hasSubstitutes(const Path & path);
|
||||||
|
@ -206,6 +208,7 @@ private:
|
||||||
SQLiteStmt stmtHasPathFailed;
|
SQLiteStmt stmtHasPathFailed;
|
||||||
SQLiteStmt stmtAddDerivationOutput;
|
SQLiteStmt stmtAddDerivationOutput;
|
||||||
SQLiteStmt stmtQueryValidDerivers;
|
SQLiteStmt stmtQueryValidDerivers;
|
||||||
|
SQLiteStmt stmtQueryDerivationOutputs;
|
||||||
|
|
||||||
int getSchema();
|
int getSchema();
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ void computeFSClosure(const Path & storePath,
|
||||||
store->queryReferences(storePath, references);
|
store->queryReferences(storePath, references);
|
||||||
|
|
||||||
if (includeOutputs && isDerivation(storePath)) {
|
if (includeOutputs && isDerivation(storePath)) {
|
||||||
Derivation drv = derivationFromPath(storePath);
|
PathSet outputs = store->queryDerivationOutputs(storePath);
|
||||||
foreach (DerivationOutputs::iterator, i, drv.outputs)
|
foreach (PathSet::iterator, i, outputs)
|
||||||
if (store->isValidPath(i->second.path))
|
if (store->isValidPath(*i))
|
||||||
computeFSClosure(i->second.path, paths, flipDirection, true);
|
computeFSClosure(*i, paths, flipDirection, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (PathSet::iterator, i, references)
|
foreach (PathSet::iterator, i, references)
|
||||||
|
|
|
@ -294,6 +294,12 @@ Path RemoteStore::queryDeriver(const Path & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PathSet RemoteStore::queryDerivationOutputs(const Path & path)
|
||||||
|
{
|
||||||
|
throw Error("not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Path RemoteStore::addToStore(const Path & _srcPath,
|
Path RemoteStore::addToStore(const Path & _srcPath,
|
||||||
bool recursive, HashType hashAlgo, PathFilter & filter)
|
bool recursive, HashType hashAlgo, PathFilter & filter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
|
|
||||||
Path queryDeriver(const Path & path);
|
Path queryDeriver(const Path & path);
|
||||||
|
|
||||||
|
PathSet queryDerivationOutputs(const Path & path);
|
||||||
|
|
||||||
bool hasSubstitutes(const Path & path);
|
bool hasSubstitutes(const Path & path);
|
||||||
|
|
||||||
bool querySubstitutablePathInfo(const Path & path,
|
bool querySubstitutablePathInfo(const Path & path,
|
||||||
|
|
|
@ -139,6 +139,9 @@ public:
|
||||||
no deriver has been set. */
|
no deriver has been set. */
|
||||||
virtual Path queryDeriver(const Path & path) = 0;
|
virtual Path queryDeriver(const Path & path) = 0;
|
||||||
|
|
||||||
|
/* Query the outputs of the derivation denoted by `path'. */
|
||||||
|
virtual PathSet queryDerivationOutputs(const Path & path) = 0;
|
||||||
|
|
||||||
/* Query whether a path has substitutes. */
|
/* Query whether a path has substitutes. */
|
||||||
virtual bool hasSubstitutes(const Path & path) = 0;
|
virtual bool hasSubstitutes(const Path & path) = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue