[Libreoffice-commits] online.git: 2 commits - loleaflet/debug loleaflet/dist loleaflet/src wsd/Admin.cpp wsd/Admin.hpp wsd/protocol.txt
Pranav Kant
pranavk at collabora.co.uk
Tue Aug 29 06:42:44 UTC 2017
loleaflet/debug/document/admin.html | 2 +-
loleaflet/dist/admin/admin.html | 2 +-
loleaflet/src/admin/AdminSocketOverview.js | 6 +++---
wsd/Admin.cpp | 14 ++++++++++++--
wsd/Admin.hpp | 4 ++++
wsd/protocol.txt | 12 +++++++++---
6 files changed, 30 insertions(+), 10 deletions(-)
New commits:
commit 29db4b447fda62913e25d66d5f6079bcb6c67ad7
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Tue Aug 29 11:31:36 2017 +0530
admin protocol: 'total_mem' -> 'mem_consumed'
total_mem can be confused with total system memory or total memory
availabe to loolwsd process. Change the API to say what it actually
returns.
Change-Id: I55c246b8a1d0c5c52767520150e55616266a6d4f
diff --git a/loleaflet/debug/document/admin.html b/loleaflet/debug/document/admin.html
index 362864ff..947fdc40 100644
--- a/loleaflet/debug/document/admin.html
+++ b/loleaflet/debug/document/admin.html
@@ -87,7 +87,7 @@
<h4>Documents opened</h4>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
- <div class="main-data" id="total_mem">0</div>
+ <div class="main-data" id="mem_consumed">0</div>
<h4>Memory consumed</h4>
</div>
</div>
diff --git a/loleaflet/dist/admin/admin.html b/loleaflet/dist/admin/admin.html
index 366d2cfb..306da27f 100644
--- a/loleaflet/dist/admin/admin.html
+++ b/loleaflet/dist/admin/admin.html
@@ -74,7 +74,7 @@
<h4><script>document.write(l10nstrings.strDocumentsOpened)</script></h4>
</div>
<div class="col-xs-6 col-sm-2 placeholder">
- <div class="main-data" id="total_mem">0</div>
+ <div class="main-data" id="mem_consumed">0</div>
<h4><script>document.write(l10nstrings.strMemoryConsumed)</script></h4>
</div>
<div class="col-xs-6 col-sm-2 placeholder">
diff --git a/loleaflet/src/admin/AdminSocketOverview.js b/loleaflet/src/admin/AdminSocketOverview.js
index da6f9a50..5e791c7a 100644
--- a/loleaflet/src/admin/AdminSocketOverview.js
+++ b/loleaflet/src/admin/AdminSocketOverview.js
@@ -13,7 +13,7 @@ var AdminSocketOverview = AdminSocketBase.extend({
_docElapsedTimeIntervalId: 0,
_getBasicStats: function() {
- this.socket.send('total_mem');
+ this.socket.send('mem_consumed');
this.socket.send('active_docs_count');
this.socket.send('active_users_count');
this.socket.send('sent_bytes');
@@ -339,7 +339,7 @@ var AdminSocketOverview = AdminSocketBase.extend({
$(document.getElementById('docListContainer_' + encodedUId)).append($docentry);
}
}
- else if (textMsg.startsWith('total_mem') ||
+ else if (textMsg.startsWith('mem_consumed') ||
textMsg.startsWith('active_docs_count') ||
textMsg.startsWith('active_users_count') ||
textMsg.startsWith('sent_bytes') ||
@@ -349,7 +349,7 @@ var AdminSocketOverview = AdminSocketBase.extend({
var sCommand = textMsg[0];
var nData = parseInt(textMsg[1]);
- if (sCommand === 'total_mem' ||
+ if (sCommand === 'mem_consumed' ||
sCommand === 'sent_bytes' ||
sCommand === 'recv_bytes') {
nData = Util.humanizeMem(nData);
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index c574aa61..206062cb 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -142,8 +142,8 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */,
model.unsubscribe(_sessionId, tokens[i + 1]);
}
}
- else if (tokens[0] == "total_mem")
- sendTextFrame("total_mem " + std::to_string(_admin->getTotalMemoryUsage()));
+ else if (tokens[0] == "mem_consumed")
+ sendTextFrame("mem_consumed " + std::to_string(_admin->getTotalMemoryUsage()));
else if (tokens[0] == "total_avail_mem")
sendTextFrame("total_avail_mem " + std::to_string(_admin->getTotalAvailableMemory()));
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index b75afe7d..4bd4258d 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -568,12 +568,12 @@ history
}
}
-total_mem
+mem_consumed
sent_bytes
recv_bytes
Queries for total memory or bandwidth being consumed by the server
- in kilobytes. For total_mem this includes processes - loolwsd,
+ in kilobytes. For mem_consumed this includes processes - loolwsd,
loolforkit, and child processes hosting various documents. For
sent/recv_bytes this includes only external traffic.
@@ -668,7 +668,13 @@ documents <pid> <filename> <number of views> <memory consumed> <elapsed time> <i
Each set document attributes is separated by a newline.
-total_mem <memory>
+mem_consumed <memory>
+ Total memory being consumed by LibreOffice Online.
+total_avail_mem <memory>
+ Total memory available to whole LibreOffice Online. This takes into account
+ the memproportion setting, if set by the user, when calculating the amount
+ of memory available to the process.
+
sent_bytes <memory>
recv_bytes <memory>
commit 65e3f7c7df67eb89ea575752fe0890c98dc29f13
Author: Pranav Kant <pranavk at collabora.co.uk>
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
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 343c841e..c574aa61 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -145,6 +145,9 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */,
else if (tokens[0] == "total_mem")
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] == "sent_bytes")
sendTextFrame("sent_bytes " + std::to_string(model.getSentBytesTotal() / 1024));
@@ -336,6 +339,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 16dc3363..3e7e0d83 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -70,6 +70,9 @@ public:
void pollingThread() override;
size_t getTotalMemoryUsage();
+ /// Takes into account the 'memproportion' property in config file to find the amount of memory
+ /// available to us.
+ size_t getTotalAvailableMemory() { return _totalAvailMem; }
size_t getTotalCpuUsage();
void modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value);
@@ -134,6 +137,7 @@ private:
uint64_t _lastSentCount;
uint64_t _lastRecvCount;
size_t _totalSysMem;
+ size_t _totalAvailMem;
std::atomic<int> _memStatsTaskIntervalMs;
std::atomic<int> _cpuStatsTaskIntervalMs;
More information about the Libreoffice-commits
mailing list