aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-10-23 15:23:25 +0200
committerGitHub <[email protected]>2023-10-23 15:23:25 +0200
commit54d0430a4507a7c1769a1587b7fc8049c7a3e575 (patch)
tree071a1804814688bc49e1ac2ad2aaddd2d1490b45 /src
parentRemove any unreferenced blocks in block store on open (#492) (diff)
downloadzen-54d0430a4507a7c1769a1587b7fc8049c7a3e575.tar.xz
zen-54d0430a4507a7c1769a1587b7fc8049c7a3e575.zip
fix m_LastFullGcDuration, m_LastFullGCDiff, m_LastFullGcDuration and m_LastLightweightGcDuration stats (#494)
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/admin/admin.cpp4
-rw-r--r--src/zenstore/gc.cpp31
-rw-r--r--src/zenstore/include/zenstore/gc.h16
3 files changed, 23 insertions, 28 deletions
diff --git a/src/zenserver/admin/admin.cpp b/src/zenserver/admin/admin.cpp
index 06a079a52..7c7c729c7 100644
--- a/src/zenserver/admin/admin.cpp
+++ b/src/zenserver/admin/admin.cpp
@@ -234,7 +234,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler,
{
Response << "SpaceToNext" << NiceBytes(State.RemainingSpaceUntilFullGC);
}
- Response << "LastDuration" << SecondsToString(State.LastFullGcDuration);
+ Response << "LastDuration" << NiceTimeSpanMs(State.LastFullGcDuration.count());
Response << "LastDiskFreed" << NiceBytes(State.LastFullGCDiff.DiskSize);
Response << "LastMemoryFreed" << NiceBytes(State.LastFullGCDiff.MemorySize);
}
@@ -243,7 +243,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler,
{
Response << "LastTime" << fmt::format("{}", State.LastLightweightGcTime);
Response << "TimeToNext" << SecondsToString(State.RemainingTimeUntilLightweightGc);
- Response << "LastDuration" << SecondsToString(State.LastLightweightGcDuration);
+ Response << "LastDuration" << NiceTimeSpanMs(State.LastLightweightGcDuration.count());
Response << "LastDiskFreed" << NiceBytes(State.LastLightweightGCDiff.DiskSize);
Response << "LastMemoryFreed" << NiceBytes(State.LastLightweightGCDiff.MemorySize);
}
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp
index 7396fcf65..24b7b4d2c 100644
--- a/src/zenstore/gc.cpp
+++ b/src/zenstore/gc.cpp
@@ -729,10 +729,12 @@ GcScheduler::GetState() const
{
std::unique_lock Lock(m_GcMutex);
- Result.LastFullGcTime = m_LastGcTime;
- Result.LastFullGCDiff = m_LastFullGCDiff;
- Result.LastLightweightGcTime = m_LastLightweightGcTime;
- Result.LastLightweightGCDiff = m_LastLightweightGCDiff;
+ Result.LastFullGcTime = m_LastGcTime;
+ Result.LastFullGCDiff = m_LastFullGCDiff;
+ Result.LastFullGcDuration = m_LastFullGcDuration;
+ Result.LastLightweightGcTime = m_LastLightweightGcTime;
+ Result.LastLightweightGCDiff = m_LastLightweightGCDiff;
+ Result.LastLightweightGcDuration = m_LastLightweightGcDuration;
}
std::error_code Ec;
DiskSpace Space = DiskSpaceInfo(Result.Config.RootDirectory, Ec);
@@ -1194,22 +1196,13 @@ GcScheduler::CollectGarbage(const GcClock::TimePoint& CacheExpireTime,
GcStorageSize Diff = m_GcManager.CollectGarbage(GcCtx);
+ std::chrono::milliseconds ElapsedMS = std::chrono::milliseconds(Timer.GetElapsedTimeMs());
+
if (SkipCid)
{
- m_LastLightweightGcTime = GcClock::Now();
-
- std::chrono::seconds ElapsedSeconds =
- std::chrono::duration_cast<std::chrono::seconds>(std::chrono::milliseconds(Timer.GetElapsedTimeMs()));
- if (SkipCid)
- {
- m_LastLightweightGcDuration = ElapsedSeconds;
- m_LastLightweightGCDiff = Diff;
- }
- else
- {
- m_LastFullGcDuration = ElapsedSeconds;
- m_LastFullGCDiff = Diff;
- }
+ m_LastLightweightGcTime = GcClock::Now();
+ m_LastLightweightGcDuration = ElapsedMS;
+ m_LastLightweightGCDiff = Diff;
}
else
{
@@ -1223,6 +1216,8 @@ GcScheduler::CollectGarbage(const GcClock::TimePoint& CacheExpireTime,
m_LastGcTime = GcClock::Now();
m_LastLightweightGcTime = m_LastGcTime;
+ m_LastFullGcDuration = ElapsedMS;
+ m_LastFullGCDiff = Diff;
}
try
diff --git a/src/zenstore/include/zenstore/gc.h b/src/zenstore/include/zenstore/gc.h
index ffdc8f066..42605804e 100644
--- a/src/zenstore/include/zenstore/gc.h
+++ b/src/zenstore/include/zenstore/gc.h
@@ -204,10 +204,10 @@ struct GcSchedulerState
std::chrono::seconds RemainingTimeUntilFullGc;
uint64_t RemainingSpaceUntilFullGC = 0;
- std::chrono::seconds LastFullGcDuration{};
- GcStorageSize LastFullGCDiff;
- std::chrono::seconds LastLightweightGcDuration{};
- GcStorageSize LastLightweightGCDiff;
+ std::chrono::milliseconds LastFullGcDuration{};
+ GcStorageSize LastFullGCDiff;
+ std::chrono::milliseconds LastLightweightGcDuration{};
+ GcStorageSize LastLightweightGCDiff;
};
class DiskUsageWindow
@@ -283,10 +283,10 @@ private:
GcClock::TimePoint m_LastLightweightGcTime{};
GcClock::TimePoint m_LastGcExpireTime{};
- std::chrono::seconds m_LastFullGcDuration{};
- GcStorageSize m_LastFullGCDiff;
- std::chrono::seconds m_LastLightweightGcDuration{};
- GcStorageSize m_LastLightweightGCDiff;
+ std::chrono::milliseconds m_LastFullGcDuration{};
+ GcStorageSize m_LastFullGCDiff;
+ std::chrono::milliseconds m_LastLightweightGcDuration{};
+ GcStorageSize m_LastLightweightGCDiff;
std::atomic_uint32_t m_Status{};
std::thread m_GcThread;