diff options
| author | Dan Engelbrecht <[email protected]> | 2022-12-02 16:56:51 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-02 07:56:51 -0800 |
| commit | 921078b38bfa91424c27ff707d950e26c18d3cd3 (patch) | |
| tree | e71446e3ebc29f7ff8ad47c0c23d8b2e49211dbe /zenserver/cache/structuredcachestore.cpp | |
| parent | reduce gc log spam (INFO -> DEBUG) (#199) (diff) | |
| download | zen-921078b38bfa91424c27ff707d950e26c18d3cd3.tar.xz zen-921078b38bfa91424c27ff707d950e26c18d3cd3.zip | |
Size based gc trigger (#197)
- Feature: Disk size triggered GC, a soft disk usage limit for cache data.
- Feature: New option `--gc-disk-size-soft-limit` (command line), `gc.cache.disksizesoftlimit` (lua config) controlling limit for soft disk usage limit. Defaults to zero which disables soft disk usage limit.
- Improvement: Disk write pressure in GC log and cleaned up clutter in GC logging.
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index 91ae452a8..c20e40655 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -1213,8 +1213,7 @@ ZenCacheDiskLayer::CacheBucket::GatherReferences(GcContext& GcCtx) NiceLatencyNs(ReadBlockLongestTimeUs)); }); - const GcClock::TimePoint ExpireTime = - GcCtx.MaxCacheDuration() == GcClock::Duration::max() ? GcClock::TimePoint::min() : GcCtx.Time() - GcCtx.MaxCacheDuration(); + const GcClock::TimePoint ExpireTime = GcCtx.ExpireTime(); const GcClock::Tick ExpireTicks = ExpireTime.time_since_epoch().count(); @@ -1310,7 +1309,7 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx) uint64_t MovedCount = 0; const auto _ = MakeGuard([&] { - ZEN_INFO( + ZEN_DEBUG( "garbage collect from '{}' DONE after {}, write lock: {} ({}), read lock: {} ({}), collected {} bytes, deleted #{} and moved " "#{} " "of #{} " @@ -2379,8 +2378,7 @@ TEST_CASE("z$.gc") GcClock::Duration MaxDuration, std::span<const IoHash> Cids, std::vector<IoHash>& OutKeep) { - GcContext GcCtx(Time); - GcCtx.MaxCacheDuration(MaxDuration); + GcContext GcCtx(Time - MaxDuration); Gc.CollectGarbage(GcCtx); OutKeep.clear(); GcCtx.FilterCids(Cids, [&OutKeep](const IoHash& Hash) { OutKeep.push_back(Hash); }); @@ -2459,8 +2457,7 @@ TEST_CASE("z$.gc") } { - GcContext GcCtx; - GcCtx.MaxCacheDuration(std::chrono::hours(46)); + GcContext GcCtx(CurrentTime - std::chrono::hours(46)); Gc.CollectGarbage(GcCtx); @@ -2474,9 +2471,7 @@ TEST_CASE("z$.gc") // Move forward in time and collect again { - GcContext GcCtx(CurrentTime + std::chrono::hours(46)); - GcCtx.MaxCacheDuration(std::chrono::minutes(2)); - + GcContext GcCtx(CurrentTime + std::chrono::minutes(2)); Gc.CollectGarbage(GcCtx); for (const auto& Key : Keys) @@ -2495,8 +2490,7 @@ TEST_CASE("z$.gc") ScopedTemporaryDirectory TempDir; GcManager Gc; ZenCacheNamespace Zcs(Gc, TempDir.Path() / "cache"); - const auto Bucket = "rightintwo"sv; - const GcClock::TimePoint CurrentTime = GcClock::Now(); + const auto Bucket = "rightintwo"sv; std::vector<IoHash> Keys{CreateKey(1), CreateKey(2), CreateKey(3)}; @@ -2507,8 +2501,7 @@ TEST_CASE("z$.gc") } { - GcContext GcCtx; - GcCtx.MaxCacheDuration(std::chrono::hours(2)); + GcContext GcCtx(GcClock::Now() - std::chrono::hours(2)); GcCtx.CollectSmallObjects(true); Gc.CollectGarbage(GcCtx); @@ -2523,8 +2516,7 @@ TEST_CASE("z$.gc") // Move forward in time and collect again { - GcContext GcCtx(CurrentTime + std::chrono::hours(2)); - GcCtx.MaxCacheDuration(std::chrono::minutes(2)); + GcContext GcCtx(GcClock::Now() + std::chrono::minutes(2)); GcCtx.CollectSmallObjects(true); Zcs.Flush(); @@ -2713,7 +2705,7 @@ TEST_CASE("z$.threadedinsert") // * doctest::skip(true)) C++; } - GcContext GcCtx; + GcContext GcCtx(GcClock::Now() - std::chrono::hours(24)); GcCtx.CollectSmallObjects(true); GcCtx.AddRetainedCids(KeepHashes); Zcs.CollectGarbage(GcCtx); @@ -2761,7 +2753,7 @@ TEST_CASE("z$.threadedinsert") // * doctest::skip(true)) C++; } - GcContext GcCtx; + GcContext GcCtx(GcClock::Now() - std::chrono::hours(24)); GcCtx.CollectSmallObjects(true); GcCtx.AddRetainedCids(KeepHashes); Zcs.CollectGarbage(GcCtx); |