about summary refs log tree commit diff
path: root/src/libstore/local-store.hh
diff options
context:
space:
mode:
authorWout Mertens <Wout.Mertens@gmail.com>2014-05-13T21·10+0200
committerWout Mertens <Wout.Mertens@gmail.com>2014-05-13T21·10+0200
commite974f20c9811c3efe09cfca9bda7816f9091c0d5 (patch)
tree57af68bc138ef6ad6cf72ec5f21dc1f06516dbc3 /src/libstore/local-store.hh
parenta84f503d863fd77de9b6ecf149399c2ca7642b75 (diff)
Preload linked hashes to speed up lookups
By preloading all inodes in the /nix/store/.links directory, we can
quickly determine of a hardlinked file was already linked to the hashed
links.
This is tolerant of removing the .links directory, it will simply
recalculate all hashes in the store.
Diffstat (limited to 'src/libstore/local-store.hh')
-rw-r--r--src/libstore/local-store.hh14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 09639e74cf4c..71229f7a69c0 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -6,6 +6,11 @@
 #include "util.hh"
 #include "pathlocks.hh"
 
+#if HAVE_TR1_UNORDERED_SET
+#include <tr1/unordered_set>
+#endif
+
+
 
 class sqlite3;
 class sqlite3_stmt;
@@ -303,7 +308,14 @@ private:
 
     void checkDerivationOutputs(const Path & drvPath, const Derivation & drv);
 
-    void optimisePath_(OptimiseStats & stats, const Path & path);
+#if HAVE_TR1_UNORDERED_SET
+    typedef std::tr1::unordered_set<ino_t> Hashes;
+#else
+    typedef std::set<ino_t> Hashes;
+#endif
+
+    void loadHashes(Hashes & hashes);
+    void optimisePath_(OptimiseStats & stats, const Path & path, Hashes & hashes);
 
     // Internal versions that are not wrapped in retry_sqlite.
     bool isValidPath_(const Path & path);