forked from lix-project/lix
nix-daemon: Disable path info cache
This is useless because the client also caches path info, and can cause problems for long-running clients like hydra-queue-runner (i.e. it may return cached info about paths that have been garbage-collected).
This commit is contained in:
parent
8decb07c31
commit
256940fc48
|
@ -242,6 +242,7 @@ Path Store::computeStorePathForText(const string & name, const string & s,
|
||||||
|
|
||||||
Store::Store(const Params & params)
|
Store::Store(const Params & params)
|
||||||
: storeDir(get(params, "store", settings.nixStore))
|
: storeDir(get(params, "store", settings.nixStore))
|
||||||
|
, state({std::stoi(get(params, "path-info-cache-size", "65536"))})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ protected:
|
||||||
|
|
||||||
struct State
|
struct State
|
||||||
{
|
{
|
||||||
LRUCache<std::string, std::shared_ptr<ValidPathInfo>> pathInfoCache{64 * 1024};
|
LRUCache<std::string, std::shared_ptr<ValidPathInfo>> pathInfoCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
Sync<State> state;
|
Sync<State> state;
|
||||||
|
@ -252,6 +252,11 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
size_t getCacheSize()
|
||||||
|
{
|
||||||
|
return state.lock()->pathInfoCache.size();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~Store() { }
|
virtual ~Store() { }
|
||||||
|
|
||||||
virtual std::string getUri() = 0;
|
virtual std::string getUri() = 0;
|
||||||
|
|
|
@ -11,7 +11,7 @@ class LRUCache
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
size_t maxSize;
|
size_t capacity;
|
||||||
|
|
||||||
// Stupid wrapper to get around circular dependency between Data
|
// Stupid wrapper to get around circular dependency between Data
|
||||||
// and LRU.
|
// and LRU.
|
||||||
|
@ -27,14 +27,16 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LRUCache(size_t maxSize) : maxSize(maxSize) { }
|
LRUCache(size_t capacity) : capacity(capacity) { }
|
||||||
|
|
||||||
/* Insert or upsert an item in the cache. */
|
/* Insert or upsert an item in the cache. */
|
||||||
void upsert(const Key & key, const Value & value)
|
void upsert(const Key & key, const Value & value)
|
||||||
{
|
{
|
||||||
|
if (capacity == 0) return;
|
||||||
|
|
||||||
erase(key);
|
erase(key);
|
||||||
|
|
||||||
if (data.size() >= maxSize) {
|
if (data.size() >= capacity) {
|
||||||
/* Retire the oldest item. */
|
/* Retire the oldest item. */
|
||||||
auto oldest = lru.begin();
|
auto oldest = lru.begin();
|
||||||
data.erase(*oldest);
|
data.erase(*oldest);
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
|
|
||||||
Sync() { }
|
Sync() { }
|
||||||
Sync(const T & data) : data(data) { }
|
Sync(const T & data) : data(data) { }
|
||||||
|
Sync(T && data) noexcept : data(std::move(data)) { }
|
||||||
|
|
||||||
class Lock
|
class Lock
|
||||||
{
|
{
|
||||||
|
|
|
@ -637,7 +637,10 @@ static void processConnection(bool trusted)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Open the store. */
|
/* Open the store. */
|
||||||
auto store = make_ref<LocalStore>(Store::Params()); // FIXME: get params from somewhere
|
Store::Params params; // FIXME: get params from somewhere
|
||||||
|
// Disable caching since the client already does that.
|
||||||
|
params["path-info-cache-size"] = "0";
|
||||||
|
auto store = make_ref<LocalStore>(params);
|
||||||
|
|
||||||
stopWork();
|
stopWork();
|
||||||
to.flush();
|
to.flush();
|
||||||
|
|
Loading…
Reference in a new issue