Make the garbage collector more concurrent

Make the garbage collector more concurrent by deleting valid paths
outside the region where we're holding the global GC lock.  This
should greatly reduce the time during which new builds are blocked,
since the deletion accounts for the vast majority of the time spent in
the GC.

To ensure that this is safe, the valid paths are invalidated and
renamed to some arbitrary path while we're holding the lock.  This
ensures that we when we finally delete the path, it's not a (newly)
valid or locked path.
This commit is contained in:
Eelco Dolstra 2012-03-26 20:43:33 +02:00
parent 8be1979f1a
commit 117670be57
3 changed files with 47 additions and 20 deletions

View file

@ -1380,11 +1380,8 @@ Paths LocalStore::importPaths(bool requireSignature, Source & source)
}
void LocalStore::deleteFromStore(const Path & path, unsigned long long & bytesFreed,
unsigned long long & blocksFreed)
void LocalStore::invalidatePathChecked(const Path & path)
{
bytesFreed = 0;
assertStorePath(path);
while (1) {
@ -1404,8 +1401,6 @@ void LocalStore::deleteFromStore(const Path & path, unsigned long long & bytesFr
break;
} catch (SQLiteBusy & e) { };
}
deletePathWrapped(path, bytesFreed, blocksFreed);
}