aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/structuredcachestore.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-10-02 11:29:00 +0200
committerGitHub <[email protected]>2023-10-02 11:29:00 +0200
commit14deb110acac35e96afa72316f6cd871dfe04168 (patch)
tree9206028a2423c01f562d6e3b45b2e2c34947b611 /src/zenserver/cache/structuredcachestore.h
parentlightweight gc (#431) (diff)
downloadzen-14deb110acac35e96afa72316f6cd871dfe04168.tar.xz
zen-14deb110acac35e96afa72316f6cd871dfe04168.zip
Limit size of memory cache layer (#423)
- Feature: Limit the size ZenCacheMemoryLayer may use - `--cache-memlayer-targetfootprint` option to set which size (in bytes) it should be limited to, zero to have it unbounded - `--cache-memlayer-maxage` option to set how long (in seconds) cache items should be kept in the memory cache Do more "standard" GC rather than clearing everything. Tries to purge memory on Get/Put on the fly if exceeding limit - not sure if we should have a polling thread instead of adding overhead to Get/Put (however light it may be).
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.h')
-rw-r--r--src/zenserver/cache/structuredcachestore.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/zenserver/cache/structuredcachestore.h b/src/zenserver/cache/structuredcachestore.h
index 0dd160a98..0c87ecc22 100644
--- a/src/zenserver/cache/structuredcachestore.h
+++ b/src/zenserver/cache/structuredcachestore.h
@@ -39,6 +39,7 @@ namespace zen {
class WorkerThreadPool;
class DiskWriteBlocker;
+class JobQueue;
/* Z$ namespace
@@ -77,7 +78,10 @@ public:
ZenCacheDiskLayer::DiskStats DiskStats;
};
- ZenCacheNamespace(GcManager& Gc, const std::filesystem::path& RootDir);
+ ZenCacheNamespace(GcManager& Gc,
+ JobQueue& JobQueue,
+ const std::filesystem::path& RootDir,
+ const ZenCacheMemoryLayer::Configuration MemLayerConfig = {});
~ZenCacheNamespace();
bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
@@ -108,6 +112,7 @@ public:
private:
std::filesystem::path m_RootDir;
+ JobQueue& m_JobQueue;
ZenCacheMemoryLayer m_MemLayer;
ZenCacheDiskLayer m_DiskLayer;
std::atomic<uint64_t> m_HitCount{};
@@ -137,8 +142,9 @@ public:
struct Configuration
{
- std::filesystem::path BasePath;
- bool AllowAutomaticCreationOfNamespaces = false;
+ std::filesystem::path BasePath;
+ bool AllowAutomaticCreationOfNamespaces = false;
+ ZenCacheMemoryLayer::Configuration MemLayerConfig;
struct LogConfig
{
bool EnableWriteLog = true;
@@ -171,7 +177,7 @@ public:
std::vector<NamedNamespaceStats> NamespaceStats;
};
- ZenCacheStore(GcManager& Gc, const Configuration& Configuration, const DiskWriteBlocker* InDiskWriteBlocker);
+ ZenCacheStore(GcManager& Gc, JobQueue& JobQueue, const Configuration& Configuration, const DiskWriteBlocker* InDiskWriteBlocker);
~ZenCacheStore();
bool Get(const CacheRequestContext& Context,
@@ -222,6 +228,7 @@ private:
std::vector<std::unique_ptr<ZenCacheNamespace>> m_DroppedNamespaces;
GcManager& m_Gc;
+ JobQueue& m_JobQueue;
Configuration m_Configuration;
std::atomic<uint64_t> m_HitCount{};
std::atomic<uint64_t> m_MissCount{};