aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenstore/gc.cpp50
2 files changed, 31 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e4c5d24df..7d4aa33f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
- Bugfix: GC logging now correctly reports used/free disk space in log message
- Improvement: Faster collection of referenced CId content in project store
- Improvement: Also reject bad bucket GET operations to prevent the buckets from being created on disk
+- Improvement: GC will now skip a lightweight GC if a full GC is due to run within the next lightweight GC interval
- Improvement: when dedicated mode is enabled via --dedicated or server.dedicated then we tune http.sys server settings to be more suitable for a shared server. Initially we tune two things:
- the thread pool used to service I/O requests allows a larger number of threads to be created when needed. The minimum thread count is unchanged but in dedicated server mode we double the maximum number of threads allowed
- the http.sys request queue length (HttpServerQueueLengthProperty) is increased to 50,000 in dedicated mode. The regular default is 1,000. A larger queue means the server will deal with small intermittent stalls (for example due to GC locking) even at higher loads like 100k req/s without rejecting requests via HTTP 503 results
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;
}