[Libreoffice-commits] online.git: wsd/Admin.cpp wsd/AdminModel.cpp wsd/AdminModel.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 30 05:11:02 UTC 2017


 wsd/Admin.cpp      |    2 +-
 wsd/AdminModel.cpp |   15 +++++++++++++--
 wsd/AdminModel.hpp |    2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

New commits:
commit cc3285e92365e6cfdf07732e575cff0c7848748f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Jan 30 00:01:49 2017 -0500

    wsd: log memory stat duration and averages
    
    Change-Id: I8c84053c52c6725d2bda2e75313c52520e4bae6e
    Reviewed-on: https://gerrit.libreoffice.org/33679
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 6cfe993..333011f 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -328,7 +328,7 @@ void MemoryStats::run()
 {
     std::unique_lock<std::mutex> modelLock(_admin->getLock());
     AdminModel& model = _admin->getModel();
-    const auto totalMem = model.getTotalMemoryUsage();
+    const auto totalMem = model.getKitsMemoryUsage();
 
     if (totalMem != _lastTotalMemory)
     {
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 5f61175..5055d90 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -129,17 +129,28 @@ std::string AdminModel::query(const std::string& command)
 }
 
 /// Returns memory consumed by all active loolkit processes
-unsigned AdminModel::getTotalMemoryUsage()
+unsigned AdminModel::getKitsMemoryUsage()
 {
+    Poco::Timestamp ts;
     unsigned totalMem = 0;
+    unsigned docs = 0;
     for (const auto& it : _documents)
     {
         if (!it.second.isExpired())
         {
-            totalMem += Util::getMemoryUsage(it.second.getPid());
+            const auto bytes = Util::getMemoryUsage(it.second.getPid());
+            if (bytes > 0)
+            {
+                totalMem += bytes;
+                ++docs;
+            }
         }
     }
 
+    LOG_INF("Got total Kits memory of " << totalMem << " bytes in " << ts.elapsed()/1001. << " ms for " <<
+            docs << " docs, avg: " << static_cast<double>(totalMem) / docs << " bytes / doc in " <<
+            ts.elapsed() / 1000. / docs << " ms per doc.");
+
     return totalMem;
 }
 
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 1dce29c..02cd78a 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -146,7 +146,7 @@ public:
     std::string query(const std::string& command);
 
     /// Returns memory consumed by all active loolkit processes
-    unsigned getTotalMemoryUsage();
+    unsigned getKitsMemoryUsage();
 
     void subscribe(int sessionId, std::shared_ptr<LOOLWebSocket>& ws);
     void subscribe(int sessionId, const std::string& command);


More information about the Libreoffice-commits mailing list