mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
Speed up GC by marking entire closures as live
This commit is contained in:
parent
0154fa30cf
commit
17e6ebcc90
1 changed files with 14 additions and 6 deletions
|
@ -654,12 +654,22 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
|||
handle it again. */
|
||||
if (dead.count(*path)) continue;
|
||||
|
||||
auto markAlive = [&]()
|
||||
{
|
||||
alive.insert(*path);
|
||||
alive.insert(start);
|
||||
try {
|
||||
StorePathSet closure;
|
||||
computeFSClosure(*path, closure);
|
||||
for (auto & p : closure)
|
||||
alive.insert(p);
|
||||
} catch (InvalidPath &) { }
|
||||
};
|
||||
|
||||
/* If this is a root, bail out. */
|
||||
if (roots.count(*path)) {
|
||||
debug("cannot delete '%s' because it's a root", printStorePath(*path));
|
||||
alive.insert(*path);
|
||||
alive.insert(start);
|
||||
return;
|
||||
return markAlive();
|
||||
}
|
||||
|
||||
if (options.action == GCOptions::gcDeleteSpecific
|
||||
|
@ -671,9 +681,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
|||
auto shared(_shared.lock());
|
||||
if (shared->tempRoots.count(hashPart)) {
|
||||
debug("cannot delete '%s' because it's a temporary root", printStorePath(*path));
|
||||
alive.insert(*path);
|
||||
alive.insert(start);
|
||||
return;
|
||||
return markAlive();
|
||||
}
|
||||
shared->pending = hashPart;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue