diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-02 11:29:00 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-02 11:29:00 +0200 |
| commit | 14deb110acac35e96afa72316f6cd871dfe04168 (patch) | |
| tree | 9206028a2423c01f562d6e3b45b2e2c34947b611 /src/zenserver/config.cpp | |
| parent | lightweight gc (#431) (diff) | |
| download | zen-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/config.cpp')
| -rw-r--r-- | src/zenserver/config.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp index 6daf7fe1c..5e24d174b 100644 --- a/src/zenserver/config.cpp +++ b/src/zenserver/config.cpp @@ -814,9 +814,17 @@ ParseConfigFile(const std::filesystem::path& Path, LuaOptions.AddOption("trace.file"sv, ServerOptions.TraceFile, "tracefile"sv); ////// cache - LuaOptions.AddOption("cache.enable"sv, ServerOptions.StructuredCacheEnabled); - LuaOptions.AddOption("cache.writelog"sv, ServerOptions.StructuredCacheWriteLogEnabled); - LuaOptions.AddOption("cache.accesslog"sv, ServerOptions.StructuredCacheAccessLogEnabled); + LuaOptions.AddOption("cache.enable"sv, ServerOptions.StructuredCacheConfig.Enabled); + LuaOptions.AddOption("cache.writelog"sv, ServerOptions.StructuredCacheConfig.WriteLogEnabled, "cache-write-log"); + LuaOptions.AddOption("cache.accesslog"sv, ServerOptions.StructuredCacheConfig.AccessLogEnabled, "cache-access-log"); + + LuaOptions.AddOption("cache.memlayer.targetfootprint"sv, + ServerOptions.StructuredCacheConfig.MemTargetFootprintBytes, + "cache-memlayer-targetfootprint"); + LuaOptions.AddOption("cache.memlayer.triminterval"sv, + ServerOptions.StructuredCacheConfig.MemTrimIntervalSeconds, + "cache-memlayer-triminterval"); + LuaOptions.AddOption("cache.memlayer.maxage"sv, ServerOptions.StructuredCacheConfig.MemMaxAgeSeconds, "cache-memlayer-maxage"); ////// cache.upstream LuaOptions.AddOption("cache.upstream.policy"sv, ServerOptions.UpstreamCacheConfig.CachePolicy, "upstream-cache-policy"sv); @@ -1236,14 +1244,35 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) "", "cache-write-log", "Whether cache write log is enabled", - cxxopts::value<bool>(ServerOptions.StructuredCacheWriteLogEnabled)->default_value("true"), + cxxopts::value<bool>(ServerOptions.StructuredCacheConfig.WriteLogEnabled)->default_value("true"), ""); options.add_option("cache", "", "cache-access-log", "Whether cache access log is enabled", - cxxopts::value<bool>(ServerOptions.StructuredCacheAccessLogEnabled)->default_value("true"), + cxxopts::value<bool>(ServerOptions.StructuredCacheConfig.AccessLogEnabled)->default_value("true"), + ""); + + options.add_option("cache", + "", + "cache-memlayer-targetfootprint", + "Max allowed memory used by cache memory layer per namespace in bytes. Default set to 536870912 (512 Mb).", + cxxopts::value<uint64_t>(ServerOptions.StructuredCacheConfig.MemTargetFootprintBytes)->default_value("536870912"), + ""); + + options.add_option("cache", + "", + "cache-memlayer-triminterval", + "Minimum time between each attempt to trim cache memory layers in seconds. Default set to 60 (1 min).", + cxxopts::value<uint64_t>(ServerOptions.StructuredCacheConfig.MemTrimIntervalSeconds)->default_value("60"), + ""); + + options.add_option("cache", + "", + "cache-memlayer-maxage", + "Maximum age of payloads when trimming cache memory layers in seconds. Default set to 86400 (1 day).", + cxxopts::value<uint64_t>(ServerOptions.StructuredCacheConfig.MemMaxAgeSeconds)->default_value("86400"), ""); options.add_option("compute", |