[Libreoffice-commits] online.git: wsd/Admin.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 2 00:33:43 UTC 2020
wsd/Admin.cpp | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
New commits:
commit 4082a462dad52151907fe71f5780cb82b0d272a7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Jun 27 16:56:51 2020 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Thu Jul 2 02:33:25 2020 +0200
wsd: admin: don't poll rapidly when cleanup is disabled
When per_document.cleanup is disabled, the time
between the last cleanup (which never happened)
grows indefinitely, which results in minimal
polling time intervals. This wastes valuable
cpu cycles unnecessarily.
When cleanup is disabled, there is no need to
calculate the next cleanup time. The maximum
is reasonable (although it should really be
infinity).
Change-Id: I71d065441c4c2ff96fe31e6a45a5ecfdd2f85d49
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97471
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 996e7b75c..02be6fcfd 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -415,14 +415,12 @@ Admin::~Admin()
void Admin::pollingThread()
{
- std::chrono::steady_clock::time_point lastCPU, lastMem, lastNet, lastCleanup;
-
_model.setThreadOwner(std::this_thread::get_id());
- lastCPU = std::chrono::steady_clock::now();
- lastMem = lastCPU;
- lastNet = lastCPU;
- lastCleanup = lastCPU;
+ std::chrono::steady_clock::time_point lastCPU = std::chrono::steady_clock::now();
+ std::chrono::steady_clock::time_point lastMem = lastCPU;
+ std::chrono::steady_clock::time_point lastNet = lastCPU;
+ std::chrono::steady_clock::time_point lastCleanup = lastCPU;
while (!isStop() && !SigUtil::getTerminationFlag() && !SigUtil::getShutdownRequestFlag())
{
@@ -484,14 +482,15 @@ void Admin::pollingThread()
lastNet = now;
}
- int cleanupWait = _cleanupIntervalMs -
- std::chrono::duration_cast<std::chrono::milliseconds>(now - lastCleanup).count();
- if (cleanupWait <= MinStatsIntervalMs / 2) // Close enough
+ int cleanupWait = _cleanupIntervalMs;
+ if (_defDocProcSettings.getCleanupSettings().getEnable())
{
- if (_defDocProcSettings.getCleanupSettings().getEnable())
+ cleanupWait
+ -= std::chrono::duration_cast<std::chrono::milliseconds>(now - lastCleanup).count();
+ if (cleanupWait <= MinStatsIntervalMs / 2) // Close enough
{
cleanupResourceConsumingDocs();
-
+
cleanupWait += _cleanupIntervalMs;
lastCleanup = now;
}
@@ -509,7 +508,8 @@ void Admin::pollingThread()
}
// Handle websockets & other work.
- const int timeout = capAndRoundInterval(std::min(std::min(std::min(cpuWait, memWait), netWait), cleanupWait));
+ const int timeout = capAndRoundInterval(
+ std::min(std::min(std::min(cpuWait, memWait), netWait), cleanupWait));
LOG_TRC("Admin poll for " << timeout << "ms.");
poll(timeout * 1000); // continue with ms for admin, settings etc.
}
More information about the Libreoffice-commits
mailing list