wsd/Admin.cpp | 16 ++++++++++++---- wsd/Admin.hpp | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-)
New commits: commit 73a6bd69a69aedf60bcf21bec2c66d3b5f30deb7 Author: Pranav Kant <[email protected]> Date: Tue Aug 29 11:17:39 2017 +0530 admin: expose total available memory to admin clients Take into reckoning the memproportion config value for total available memory to us. Change-Id: Ib93c88d746268f3e9f566beed7df77357d530eba (cherry picked from commit 65e3f7c7df67eb89ea575752fe0890c98dc29f13) Reviewed-on: https://gerrit.libreoffice.org/41686 Reviewed-by: Jan Holesovsky <[email protected]> Tested-by: Jan Holesovsky <[email protected]> diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index 1e811dca..53bbc924 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -135,10 +135,11 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */, } } else if (tokens[0] == "total_mem") - { - const auto totalMem = _admin->getTotalMemoryUsage(); - sendTextFrame("total_mem " + std::to_string(totalMem)); - } + sendTextFrame("total_mem " + std::to_string(_admin->getTotalMemoryUsage())); + + else if (tokens[0] == "total_avail_mem") + sendTextFrame("total_avail_mem " + std::to_string(_admin->getTotalAvailableMemory())); + else if (tokens[0] == "kill" && tokens.count() == 2) { try @@ -294,6 +295,13 @@ Admin::Admin() : _totalSysMem = Util::getTotalSystemMemory(); LOG_TRC("Total system memory : " << _totalSysMem); + const auto memLimit = LOOLWSD::getConfigValue<double>("memproportion", static_cast<double>(0.0)); + _totalAvailMem = _totalSysMem; + if (memLimit != 0.0) + _totalAvailMem = _totalSysMem * memLimit/100.; + + LOG_TRC("Total available memory: " << _totalAvailMem << " (memproportion: " << memLimit << ")."); + const auto totalMem = getTotalMemoryUsage(); LOG_TRC("Total memory used: " << totalMem); _model.addMemStats(totalMem); diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp index 65ca3243..978a5ade 100644 --- a/wsd/Admin.hpp +++ b/wsd/Admin.hpp @@ -70,6 +70,9 @@ public: void pollingThread() override; unsigned getTotalMemoryUsage(); + /// Takes into account the 'memproportion' property in config file to find the amount of memory + /// available to us. + size_t getTotalAvailableMemory() { return _totalAvailMem; } void modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value); /// Update the Admin Model. @@ -114,6 +117,7 @@ private: int _forKitPid; size_t _lastTotalMemory; size_t _totalSysMem; + size_t _totalAvailMem; std::atomic<int> _memStatsTaskIntervalMs; std::atomic<int> _cpuStatsTaskIntervalMs; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
