diff options
| author | Dan Engelbrecht <[email protected]> | 2023-01-13 07:41:36 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-13 07:41:36 -0800 |
| commit | 3a501340b758dbe3c9543ed53c3d6d89a936649f (patch) | |
| tree | f3e5c4a205587b994e8f596e6b54548704e0687c /zenstore/gc.cpp | |
| parent | zen command line tool improvements (#212) (diff) | |
| download | zen-3a501340b758dbe3c9543ed53c3d6d89a936649f.tar.xz zen-3a501340b758dbe3c9543ed53c3d6d89a936649f.zip | |
fix gc logging (#213)
* Don't output time to next GC if time is "infinite".
* Do immediate check of GC status on thread startup instead of waiting montior intervall first.
* set up reasonable gc defaults
* changelog
Diffstat (limited to 'zenstore/gc.cpp')
| -rw-r--r-- | zenstore/gc.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index cb155dad1..8d3b8d018 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -666,7 +666,7 @@ GcScheduler::Trigger(const GcScheduler::TriggerParams& Params) void GcScheduler::SchedulerThread() { - std::chrono::seconds WaitTime = m_Config.MonitorInterval; + std::chrono::seconds WaitTime{0}; for (;;) { @@ -682,7 +682,13 @@ GcScheduler::SchedulerThread() break; } - if (!m_Config.Enabled || (!Timeout && Status() == GcSchedulerStatus::kIdle)) + if (!m_Config.Enabled) + { + WaitTime = std::chrono::seconds::max(); + continue; + } + + if (!Timeout && Status() == GcSchedulerStatus::kIdle) { continue; } @@ -721,8 +727,6 @@ GcScheduler::SchedulerThread() ZEN_WARN("get disk space info FAILED, reason: '{}'", Ec.message()); } - std::chrono::seconds RemaingTime = std::chrono::duration_cast<std::chrono::seconds>(m_NextGcTime - GcClock::Now()); - const int64_t PressureGraphLength = 30; const std::chrono::duration LoadGraphTime = PressureGraphLength * m_Config.MonitorInterval; std::vector<uint64_t> DiskDeltas; @@ -741,11 +745,6 @@ GcScheduler::SchedulerThread() MaxLoad); } - if (RemaingTime < std::chrono::seconds::zero()) - { - RemaingTime = std::chrono::seconds::zero(); - } - std::string LoadGraph; LoadGraph.resize(DiskDeltas.size(), '0'); if (DiskDeltas.size() > 0 && MaxLoad > 0) @@ -772,20 +771,30 @@ GcScheduler::SchedulerThread() } bool DiskSpaceGCTriggered = GcDiskSpaceGoal > 0; + + std::chrono::seconds RemaingTime = std::chrono::duration_cast<std::chrono::seconds>(m_NextGcTime - GcClock::Now()); + + if (RemaingTime < std::chrono::seconds::zero()) + { + RemaingTime = std::chrono::seconds::zero(); + } + bool TimeBasedGCTriggered = !DiskSpaceGCTriggered && RemaingTime.count() == 0; - ZEN_INFO("{} in use,{} {} of total {} free disk space, disk writes last {} per {} [{}], peak {}/s. {}", - NiceBytes(TotalSize.DiskSize), - DiskSizeSoftLimit == 0 ? "" : fmt::format(" {} soft limit,", NiceBytes(DiskSizeSoftLimit)), - NiceBytes(Space.Free), - NiceBytes(Space.Total), - NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(LoadGraphTime).count())), - NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(LoadGraphTime).count() / PressureGraphLength)), - LoadGraph, - NiceBytes(MaxLoad * uint64_t(std::chrono::seconds(1).count()) / uint64_t(std::chrono::seconds(LoadGraphTime).count())), - DiskSpaceGCTriggered ? fmt::format("Disk use threshold triggered, trying to reclaim {}. ", NiceBytes(GcDiskSpaceGoal)) - : TimeBasedGCTriggered ? "GC schedule triggered." - : fmt::format("{} until next scheduled GC.", - NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(RemaingTime).count())))); + ZEN_INFO( + "{} in use,{} {} of total {} free disk space, disk writes last {} per {} [{}], peak {}/s. {}", + NiceBytes(TotalSize.DiskSize), + DiskSizeSoftLimit == 0 ? "" : fmt::format(" {} soft limit,", NiceBytes(DiskSizeSoftLimit)), + NiceBytes(Space.Free), + NiceBytes(Space.Total), + NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(LoadGraphTime).count())), + NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(LoadGraphTime).count() / PressureGraphLength)), + LoadGraph, + NiceBytes(MaxLoad * uint64_t(std::chrono::seconds(1).count()) / uint64_t(std::chrono::seconds(LoadGraphTime).count())), + DiskSpaceGCTriggered ? fmt::format("Disk use threshold triggered, trying to reclaim {}. ", NiceBytes(GcDiskSpaceGoal)) + : TimeBasedGCTriggered ? "GC schedule triggered." + : m_NextGcTime == GcClock::TimePoint::max() + ? "" + : fmt::format("{} until next scheduled GC.", NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(RemaingTime).count())))); if (!DiskSpaceGCTriggered && !TimeBasedGCTriggered) { |