aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/binary-cache-store.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-19 18:50:15 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-19 18:52:53 +0200
commite0204f8d462041387651af388074491fd0bf36d6 (patch)
treeecd20759ce49499722d140d653c5678051bcdfc2 /src/libstore/binary-cache-store.hh
parent608b0265e104b4a97f51e5745b1a32078770f3cf (diff)
Move path info caching from BinaryCacheStore to Store
Caching path info is generally useful. For instance, it speeds up "nix path-info -rS /run/current-system" (i.e. showing the closure sizes of all paths in the closure of the current system) from 5.6s to 0.15s. This also eliminates some APIs like Store::queryDeriver() and Store::queryReferences().
Diffstat (limited to 'src/libstore/binary-cache-store.hh')
-rw-r--r--src/libstore/binary-cache-store.hh44
1 files changed, 2 insertions, 42 deletions
diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh
index 95e5d68b7..4e4346a43 100644
--- a/src/libstore/binary-cache-store.hh
+++ b/src/libstore/binary-cache-store.hh
@@ -3,8 +3,6 @@
#include "crypto.hh"
#include "store-api.hh"
-#include "lru-cache.hh"
-#include "sync.hh"
#include "pool.hh"
#include <atomic>
@@ -22,13 +20,6 @@ private:
std::shared_ptr<Store> localStore;
- struct State
- {
- LRUCache<Path, std::shared_ptr<NarInfo>> narInfoCache{64 * 1024};
- };
-
- Sync<State> state;
-
protected:
BinaryCacheStore(std::shared_ptr<Store> localStore, const Path & secretKeyFile);
@@ -47,42 +38,17 @@ public:
virtual void init();
- struct Stats
- {
- std::atomic<uint64_t> narInfoRead{0};
- std::atomic<uint64_t> narInfoReadAverted{0};
- std::atomic<uint64_t> narInfoMissing{0};
- std::atomic<uint64_t> narInfoWrite{0};
- std::atomic<uint64_t> narInfoCacheSize{0};
- std::atomic<uint64_t> narRead{0};
- std::atomic<uint64_t> narReadBytes{0};
- std::atomic<uint64_t> narReadCompressedBytes{0};
- std::atomic<uint64_t> narWrite{0};
- std::atomic<uint64_t> narWriteAverted{0};
- std::atomic<uint64_t> narWriteBytes{0};
- std::atomic<uint64_t> narWriteCompressedBytes{0};
- std::atomic<uint64_t> narWriteCompressionTimeMs{0};
- };
-
- const Stats & getStats();
-
private:
- Stats stats;
-
std::string narMagic;
std::string narInfoFileFor(const Path & storePath);
void addToCache(const ValidPathInfo & info, const string & nar);
-protected:
-
- NarInfo readNarInfo(const Path & storePath);
-
public:
- bool isValidPath(const Path & path) override;
+ bool isValidPathUncached(const Path & path) override;
PathSet queryValidPaths(const PathSet & paths) override
{ notImpl(); }
@@ -90,18 +56,12 @@ public:
PathSet queryAllValidPaths() override
{ notImpl(); }
- ValidPathInfo queryPathInfo(const Path & path) override;
-
- Hash queryPathHash(const Path & path) override
- { notImpl(); }
+ std::shared_ptr<ValidPathInfo> queryPathInfoUncached(const Path & path) override;
void queryReferrers(const Path & path,
PathSet & referrers) override
{ notImpl(); }
- Path queryDeriver(const Path & path) override
- { return ""; }
-
PathSet queryValidDerivers(const Path & path) override
{ return {}; }