wsd: reduce memory load only when the footprint changes

Update the network interval when updating the memory interval,
since we currently don't support changing the network interval.
Also make the default memory and network interval twice
that of the cpu interval explicitly.

Reduce logging noise a bit without losing information.

And some const-correctness and other cleanups.

Change-Id: I313fb2882675f560091e5113dbdcbdef269828e2
Reviewed-on: https://gerrit.libreoffice.org/49571
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian
2018-02-11 15:28:19 -05:00
committed by Ashod Nakashian
parent 2562d8919a
commit 88619a323f
2 changed files with 42 additions and 29 deletions

View File

@ -126,6 +126,14 @@ private:
/// under @hardModeLimit
void triggerMemoryCleanup(size_t hardModeLimit);
/// Round the interval up to multiples of MinStatsIntervalMs.
/// This is to avoid arbitrarily small intervals that hammer the server.
static int capAndRoundInterval(const unsigned interval)
{
const int value = std::max<int>(interval, MinStatsIntervalMs);
return ((value + MinStatsIntervalMs - 1) / MinStatsIntervalMs) * MinStatsIntervalMs;
}
private:
/// The model is accessed only during startup & in
/// the Admin Poll thread.
@ -139,13 +147,14 @@ private:
size_t _totalSysMemKb;
size_t _totalAvailMemKb;
std::atomic<int> _memStatsTaskIntervalMs;
std::atomic<int> _cpuStatsTaskIntervalMs;
std::atomic<int> _networkStatsIntervalMs;
std::atomic<int> _memStatsTaskIntervalMs;
std::atomic<int> _netStatsTaskIntervalMs;
DocProcSettings _defDocProcSettings;
// Don't update any more frequently than this since it's excessive.
const int MinStatsIntervalMs = 50;
static const int MinStatsIntervalMs = 50;
static const int DefStatsIntervalMs = 2500;
};
#endif