loolwsd/LOOLKit.cpp | 20 ++++++++++++++++++ loolwsd/MessageQueue.cpp | 51 ++++++++++++++++++----------------------------- loolwsd/TileDesc.hpp | 15 +++++++++++++ 3 files changed, 55 insertions(+), 31 deletions(-)
New commits: commit 5905c3b3f271061ee4a711c77dd2615f764d7238 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Sep 25 21:30:56 2016 -0400 loolwsd: combine single rows only Combining as much as possible is too aggressive and seems to harm performance where large areas are invalidated during editing (f.e. inserting text at the begining of a paragraph). With this patch we only combine a single row at a time. This is reasonable since rows almost always are invalidated when a line is edited. Larger blocks are typically less important. This is experimental and might get reverted if proves to harm more than help. Change-Id: I6e4420e07a031805c1e2729b3f32de580ae4806e Reviewed-on: https://gerrit.libreoffice.org/29289 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp index e845800..17b3bf8 100644 --- a/loolwsd/MessageQueue.cpp +++ b/loolwsd/MessageQueue.cpp @@ -201,43 +201,32 @@ MessageQueue::Payload TileQueue::get_impl() tiles.emplace_back(TileDesc::parse(msg)); // Combine as many tiles as possible with the top one. - bool added; - do + for (size_t i = 0; i < _queue.size(); ) { - added = false; - for (size_t i = 0; i < _queue.size(); ) + auto& it = _queue[i]; + msg = std::string(it.data(), it.size()); + if (msg.compare(0, 5, "tile ") != 0 || + msg.find("id=") != std::string::npos) { - auto& it = _queue[i]; - msg = std::string(it.data(), it.size()); - if (msg.compare(0, 5, "tile ") != 0 || - msg.find("id=") != std::string::npos) - { - // Don't combine non-tiles or tiles with id. - ++i; - continue; - } + // Don't combine non-tiles or tiles with id. + ++i; + continue; + } - auto tile2 = TileDesc::parse(msg); - Log::trace() << "combining candidate: " << msg << Log::end; + auto tile2 = TileDesc::parse(msg); + Log::trace() << "combining candidate: " << msg << Log::end; - // Check if adjacent tiles. - bool found = false; - for (auto& tile : tiles) - { - if (tile.isAdjacent(tile2)) - { - tiles.emplace_back(tile2); - _queue.erase(_queue.begin() + i); - found = true; - added = true; - break; - } - } - - i += !found; + // Check if it's on the same row. + if (tiles[0].onSameRow(tile2)) + { + tiles.emplace_back(tile2); + _queue.erase(_queue.begin() + i); + } + else + { + ++i; } } - while (added); Log::trace() << "Combined " << tiles.size() << " tiles, leaving " << _queue.size() << " in queue." << Log::end; diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp index 20ac257..7a42135 100644 --- a/loolwsd/TileDesc.hpp +++ b/loolwsd/TileDesc.hpp @@ -90,6 +90,21 @@ public: return intersects(other); } + bool onSameRow(const TileDesc& other) const + { + if (other.getPart() != getPart() || + other.getWidth() != getWidth() || + other.getHeight() != getHeight() || + other.getTileWidth() != getTileWidth() || + other.getTileHeight() != getTileHeight()) + { + return false; + } + + return other.getTilePosY() + other.getTileHeight() >= getTilePosY() && + other.getTilePosY() <= getTilePosY() + getTileHeight(); + } + /// Serialize this instance into a string. /// Optionally prepend a prefix. std::string serialize(const std::string& prefix = "") const commit 5daf4ab341851fe12e59b4cb29529af65093e3a6 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Sep 25 21:30:37 2016 -0400 loolwsd: don't process callbacks or queue messages if terminating Change-Id: I1ff75d01a0f24ba3b9d7ca2003f1633d0aa494e0 Reviewed-on: https://gerrit.libreoffice.org/29288 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 5633536..cc35ad4 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -785,6 +785,11 @@ private: static void GlobalCallback(const int nType, const char* pPayload, void* pData) { + if (TerminationFlag) + { + return; + } + const std::string payload = pPayload ? pPayload : "(nil)"; Log::trace() << "Document::GlobalCallback " << LOKitHelper::kitCallbackTypeToString(nType) @@ -804,6 +809,11 @@ private: static void ViewCallback(const int nType, const char* pPayload, void* pData) { + if (TerminationFlag) + { + return; + } + CallbackDescriptor* pDescr = reinterpret_cast<CallbackDescriptor*>(pData); assert(pDescr && "Null callback data."); assert(pDescr->Doc && "Null Document instance."); @@ -857,6 +867,11 @@ private: static void DocumentCallback(const int nType, const char* pPayload, void* pData) { + if (TerminationFlag) + { + return; + } + const std::string payload = pPayload ? pPayload : "(nil)"; Log::trace() << "Document::DocumentCallback " << LOKitHelper::kitCallbackTypeToString(nType) @@ -1175,6 +1190,11 @@ private: while (!_stop && !TerminationFlag) { const auto input = _tileQueue->get(); + if (_stop || TerminationFlag) + { + break; + } + const std::string message(input.data(), input.size()); StringTokenizer tokens(message, " "); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits