From 117670be570d775a18e4e35db3dae00abc24f729 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 26 Mar 2012 20:43:33 +0200 Subject: 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. --- src/libstore/local-store.hh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/libstore/local-store.hh') diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 2739c4eea69d..8e3cbe5ce11b 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -164,10 +164,6 @@ public: void collectGarbage(const GCOptions & options, GCResults & results); - /* Delete a path from the Nix store. */ - void deleteFromStore(const Path & path, unsigned long long & bytesFreed, - unsigned long long & blocksFreed); - /* Optimise the disk space usage of the Nix store by hard-linking files with the same contents. */ void optimiseStore(bool dryRun, OptimiseStats & stats); @@ -238,6 +234,9 @@ private: void invalidatePath(const Path & path); + /* Delete a path from the Nix store. */ + void invalidatePathChecked(const Path & path); + void verifyPath(const Path & path, const PathSet & store, PathSet & done, PathSet & validPaths); @@ -249,6 +248,8 @@ private: struct GCState; + void deleteGarbage(GCState & state, const Path & path); + bool tryToDelete(GCState & state, const Path & path); bool isActiveTempFile(const GCState & state, -- cgit 1.4.1