aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-10-12 10:18:53 +0200
committerGitHub <[email protected]>2023-10-12 10:18:53 +0200
commit6ab44e95d77f711e43f9e1465facd16082442c6a (patch)
treebf69eea67fd2171168398c25610c5055b7d771a2 /src
parentadjust resource usage for dedicated servers (#466) (diff)
downloadzen-6ab44e95d77f711e43f9e1465facd16082442c6a.tar.xz
zen-6ab44e95d77f711e43f9e1465facd16082442c6a.zip
skip lightweight GC if full GC is due soon (#467)
GC will now skip a lightweight GC if a full GC is due to run within the next lightweight GC interval also fixed some minor typos
Diffstat (limited to 'src')
-rw-r--r--src/zenstore/gc.cpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp
index bddc3a42a..0f3f178d6 100644
--- a/src/zenstore/gc.cpp
+++ b/src/zenstore/gc.cpp
@@ -793,7 +793,7 @@ GcScheduler::SchedulerThread()
bool DoDelete = true;
bool CollectSmallObjects = m_Config.CollectSmallObjects;
std::chrono::seconds GcInterval = m_Config.Interval;
- std::chrono::seconds LightwightGcInterval = m_Config.LightweightInterval;
+ std::chrono::seconds LightweightGcInterval = m_Config.LightweightInterval;
std::chrono::seconds MaxCacheDuration = m_Config.MaxCacheDuration;
std::chrono::seconds MaxProjectStoreDuration = m_Config.MaxProjectStoreDuration;
uint64_t DiskSizeSoftLimit = m_Config.DiskSizeSoftLimit;
@@ -914,38 +914,48 @@ GcScheduler::SchedulerThread()
}
}
- std::chrono::seconds RemaingTimeUntilGc =
+ std::chrono::seconds RemainingTimeUntilGc =
GcInterval.count() == 0 ? std::chrono::seconds::max()
: std::chrono::duration_cast<std::chrono::seconds>(m_LastGcTime + GcInterval - GcClock::Now());
- if (RemaingTimeUntilGc < std::chrono::seconds::zero())
+
+ if (RemainingTimeUntilGc < std::chrono::seconds::zero())
+ {
+ RemainingTimeUntilGc = std::chrono::seconds::zero();
+ }
+
+ std::chrono::seconds RemainingTimeUntilLightweightGc =
+ LightweightGcInterval.count() == 0 ? std::chrono::seconds::max()
+ : std::chrono::duration_cast<std::chrono::seconds>(
+ m_LastLightweightGcTime + LightweightGcInterval - GcClock::Now());
+
+ if (RemainingTimeUntilLightweightGc < std::chrono::seconds::zero())
{
- RemaingTimeUntilGc = std::chrono::seconds::zero();
+ RemainingTimeUntilLightweightGc = std::chrono::seconds::zero();
}
- std::chrono::seconds RemaingTimeUntilLightweightGc =
- LightwightGcInterval.count() == 0
- ? std::chrono::seconds::max()
- : std::chrono::duration_cast<std::chrono::seconds>(m_LastLightweightGcTime + LightwightGcInterval - GcClock::Now());
- if (RemaingTimeUntilLightweightGc < std::chrono::seconds::zero())
+
+ // Don't schedule a lightweight GC if a full GC is
+ // due quite soon anyway
+ if (RemainingTimeUntilGc < LightweightGcInterval)
{
- RemaingTimeUntilLightweightGc = std::chrono::seconds::zero();
+ RemainingTimeUntilLightweightGc = RemainingTimeUntilGc;
}
if (GcDiskSpaceGoal > 0)
{
DiskSpaceGCTriggered = true;
}
- else if (RemaingTimeUntilGc.count() == 0)
+ else if (RemainingTimeUntilGc.count() == 0)
{
TimeBasedGCTriggered = true;
}
- else if (RemaingTimeUntilLightweightGc.count() == 0)
+ else if (RemainingTimeUntilLightweightGc.count() == 0)
{
TimeBasedGCTriggered = true;
SkipCid = true;
}
std::string NextTriggerStatus;
- if (GcInterval.count() != 0 || LightwightGcInterval.count() != 0 || DiskSizeSoftLimit != 0)
+ if (GcInterval.count() != 0 || LightweightGcInterval.count() != 0 || DiskSizeSoftLimit != 0)
{
ExtendableStringBuilder<256> Sb;
if (DiskSpaceGCTriggered)
@@ -970,13 +980,13 @@ GcScheduler::SchedulerThread()
if (GcInterval.count() != 0)
{
Sb.Append(fmt::format(" Full GC in {}.",
- NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(RemaingTimeUntilGc).count()))));
+ NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(RemainingTimeUntilGc).count()))));
}
- if (LightwightGcInterval.count() != 0)
+ if (LightweightGcInterval.count() != 0)
{
Sb.Append(
fmt::format(" Lightweight GC in {}.",
- NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(RemaingTimeUntilLightweightGc).count()))));
+ NiceTimeSpanMs(uint64_t(std::chrono::milliseconds(RemainingTimeUntilLightweightGc).count()))));
}
if (DiskSizeSoftLimit != 0 && DiskSizeSoftLimit > TotalSize.DiskSize)
{
@@ -1002,13 +1012,13 @@ GcScheduler::SchedulerThread()
if (!DiskSpaceGCTriggered && !TimeBasedGCTriggered)
{
WaitTime = m_Config.MonitorInterval;
- if (RemaingTimeUntilGc < WaitTime)
+ if (RemainingTimeUntilGc < WaitTime)
{
- WaitTime = RemaingTimeUntilGc;
+ WaitTime = RemainingTimeUntilGc;
}
- if (RemaingTimeUntilLightweightGc < WaitTime)
+ if (RemainingTimeUntilLightweightGc < WaitTime)
{
- WaitTime = RemaingTimeUntilLightweightGc;
+ WaitTime = RemainingTimeUntilLightweightGc;
}
continue;
}