common/Session.cpp | 12 ++++++++++++ common/Session.hpp | 2 ++ net/Socket.hpp | 16 ++++++++-------- wsd/DocumentBroker.cpp | 19 +++++++++++++++++++ wsd/DocumentBroker.hpp | 2 ++ 5 files changed, 43 insertions(+), 8 deletions(-)
New commits: commit 3101fa510d4f86301d81ae76a64b7c780ae69e19 Author: Michael Meeks <michael.me...@collabora.com> Date: Thu Jun 1 03:40:01 2017 +0100 Accumulate I/O stats per document. Change-Id: Ie2f5647e65070ddd828f048820efd38b600f9133 diff --git a/common/Session.cpp b/common/Session.cpp index 44293a18..97933c83 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -203,6 +203,18 @@ void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector<char> & } } +void Session::getIOStats(uint64_t &sent, uint64_t &recv) +{ + auto socket = _socket.lock(); + if (socket) + socket->getIOStats(sent, recv); + else + { + sent = 0; + recv = 0; + } +} + void Session::dumpState(std::ostream& os) { WebSocketHandler::dumpState(os); diff --git a/common/Session.hpp b/common/Session.hpp index 63872c08..5a154ee1 100644 --- a/common/Session.hpp +++ b/common/Session.hpp @@ -82,6 +82,8 @@ public: void closeFrame() { _isCloseFrame = true; }; bool isCloseFrame() const { return _isCloseFrame; } + void getIOStats(uint64_t &sent, uint64_t &recv); + protected: Session(const std::string& name, const std::string& id, bool readonly); virtual ~Session(); diff --git a/net/Socket.hpp b/net/Socket.hpp index a7cc426d..4c410d23 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -818,6 +818,12 @@ public: return socket; } + void getIOStats(uint64_t &sent, uint64_t &recv) + { + sent = _bytesSent; + recv = _bytesRecvd; + } + protected: /// Called when a polling event is received. @@ -947,12 +953,6 @@ protected: void dumpState(std::ostream& os) override; - void getStats(uint64_t &sent, uint64_t &recv) - { - sent = _bytesSent; - recv = _bytesRecvd; - } - protected: /// Client handling the actual data. std::shared_ptr<SocketHandlerInterface> _socketHandler; @@ -966,8 +966,8 @@ protected: std::vector< char > _inBuffer; std::vector< char > _outBuffer; - std::atomic<uint64_t> _bytesSent; - std::atomic<uint64_t> _bytesRecvd; + uint64_t _bytesSent; + uint64_t _bytesRecvd; // To be able to access _inBuffer and _outBuffer. // TODO we probably need accessors to the _inBuffer & _outBuffer diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index d92df509..ac7db55f 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1430,10 +1430,27 @@ void DocumentBroker::updateLastActivityTime() Admin::instance().updateLastActivityTime(_docKey); } +void DocumentBroker::getIOStats(uint64_t &sent, uint64_t &recv) +{ + sent = 0; + recv = 0; + assertCorrectThread(); + for (const auto& sessionIt : _sessions) + { + uint64_t s, r; + sessionIt.second->getIOStats(s, r); + sent += s; + recv += r; + } +} + void DocumentBroker::dumpState(std::ostream& os) { std::unique_lock<std::mutex> lock(_mutex); + uint64_t sent, recv; + getIOStats(sent, recv); + os << " Broker: " << _filename << " pid: " << getPid(); if (_markToDestroy) os << " *** Marked to destroy ***"; @@ -1443,6 +1460,8 @@ void DocumentBroker::dumpState(std::ostream& os) os << "\n loaded in: " << _loadDuration.count() << "ms"; else os << "\n still loading..."; + os << "\n sent: " << sent; + os << "\n recv?: " << recv; os << "\n modified?: " << _isModified; os << "\n jail id: " << _jailId; os << "\n filename: " << _filename; diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 1329fcb1..2c244fe1 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -367,6 +367,8 @@ private: /// associated with this document. void pollThread(); + void getIOStats(uint64_t &sent, uint64_t &recv); + private: const std::string _uriOrig; const Poco::URI _uriPublic; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits