Commit Graph

56 Commits (master)

Author SHA1 Message Date
Michael Meeks a6678b554a Cleanup and shorten tilecombine descriptor lists.
If we have all default values of imgSize, wid, old-wid then we
should simply not serialize these out to save space and improve
readability.

Unfortunately, this means that we need to catch the mutation of
the TileCombined's content in two places; now just one. Building
the queue of rendered tiles to send back is now moved and
wrapped into a TileCombinedBuilder class - this also lets us
stop serialize taking a random vectors of TileDescs. However
the DocumentBroker::handleTileCombinedRequest method needs to
set the force-keyframe oldWid=0 flag on individual tiles and
then update the TileCombined.

Ideally we would have a nice visitor API and drop the non-const
getTiles() method that returns a reference to our internal vector.

Update tests, to not have redundant attributes, and add more tests
to ensure redundant attributes are removed.

Change-Id: Id76d3ae14d459d73bbae8112d840dea27f66588b
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-05-26 19:28:30 +01:00
Michael Meeks 69c6739e47 cool#9145 - KitQueue: re-work _tileQueue to use TileDesc.
This stops a huge amount of parsing, re-parsing and conversion
from strings and back, making our few N^2 loops over the tiles
much more efficient.

Retain queue tests with the same strings via using a helper
to convert back to something expected.

Replace TileDesc::getId() with isPreview().

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If40fc45f1fb474d37371e4b949da5fdfc594fdc8
2024-05-23 19:50:09 +01:00
Caolán McNamara 8640baba46 "Invalid tilecombine descriptor" seen without explanation
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I0635ce3897866953aec9fbbee35cd04f896e845a
2024-05-23 17:12:26 +02:00
Michael Meeks 030895c754 cool#9120 - use a simple hash to avoid most tile: comparisons.
Parsing a string to a TileDesc and then comparing is inefficient
enough, without doing that in an N^2 loop for the SenderQueue.

Still N^2 - and of dubious value in the world of deltas; but in
almost all cases a simple string + integer compare.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ibe8230679e27b98cfa95567fea700e2f7d5ac09c
2024-05-22 19:58:28 +01:00
Ashod Nakashian 61cf7b9601 wsd: clean up unused header includes
Clang-tidy recommendation driven header
include clean-up.

Change-Id: I30c32866b7798e70df0463ee6bc7a0bcc3de5049
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-08 08:38:48 +01:00
Michael Meeks 7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Michael Meeks 47b89b32ef spdx: improve machine and human readability of headers.
Change-Id: I1b6dcd2ec1fbef6556d70b8af3ccfd5d6a95c59a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-10-31 10:33:07 +00:00
Caolán McNamara 395d6c9f12 Assertion in DocumentBroker::sendRequestedTiles fails on running cypress impress tests
make -C cypress_test check-desktop

asserts seen in cypress_test/cypress/wsd_logs/coolwsd_output.log of:

coolwsd: wsd/DocumentBroker.cpp:3134: void DocumentBroker::sendTileCombine(const TileCombined&): Assertion `!newTileCombined.hasDuplicates()' failed.

If we check for, and don't reuse, an old request with a different
NormalizedViewId then we could end up with multiple requests with
different NormalizedViewIds that end up in the same final tilecombine.

similarly there was no check for different modes ending up in the
same tilecombine.

just split out the logic we have to see if two tiles have the same
properties that appear as a shared set of properties for tilecombine
and use that in the two relevant places.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ieb2ee0e85f124dd57c6b050e5b669dd808cf6bbf
2023-10-17 17:05:24 +01:00
Caolán McNamara 131d503b93 reduce cost of TileCombined::parse
perf reported 1% of time in collaborative multi user test
on 2023-09-14 was spent in TileCombined::parse.

generic-ize and reuse the TileDesc::parse approach for
TileCombined::parse to avoid need for std::unordered_map

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iadfc2001e298d8f4d46200c8488f0eb4cd8734c2
2023-10-02 20:05:07 +01:00
Caolán McNamara 084e715dc6 TileDesc broadcast field is always false
apparently since:

commit b0a7532b08
Date:   Sat Nov 14 19:43:02 2020 +0300

    Turn off broadcast on presentation preview tiles

so drop this field from TileDesc and protocol.txt

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib4b1eca0d30911e13c245551cb3e3261afc99dd2
2023-09-11 09:38:49 +01:00
Caolán McNamara 3b7ef07997 getTokenString is another loop over the tokens that we already loop over
getTokenString(const StringVector& tokens...) loops over each
token and calls
getTokenString(const std::string&...) with token.getParam() on each
token. We already have a loop over each token, so we can merge those
loops here.

perf reports TileDesc::parse taking 3.68% of the time in a hour
of an interactive writer session with multiple participants

Though looking further, broadcast seems unused by anything now.

To be followed up on that topic.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I244637043c58d90562001ec58fac494da54e55a8
2023-09-11 09:38:49 +01:00
Caolán McNamara afe6c1bed8 reduce cost of TileDesc::parse
perf reported 6.58% of time in collaborative multi user test
on 2023-08-24 was spent in TileDesc::parse and much of that
in std::unordered_map.

There are only 12 arguments in the map we care about here so
we can just used a sorted array, look by name on write, and
read by index.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iadfc2001e298d8f4d46200c8488f0eb4cd8734c2
2023-08-24 22:22:43 +01:00
Caolán McNamara 6d5c78dec0 move "combined" bit inside TileCombined class
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I274c5844660acbf69e50587cce3f4ddcae414723
2023-08-21 20:48:31 +01:00
Szymon Kłos 7043365475 masterpage: get & set optional mode parameter for tiles (server side)
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I756e3d515c86a635cfa9db81106848ee3dcf684a
2022-09-19 15:18:23 +02:00
Szymon Kłos 06fbc53c9d masterpage: get & set optional mode parameter for tiles
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ied50985f85db385fb38cfb9c4006e3b87119e9fc
2022-09-19 15:18:23 +02:00
Michael Meeks b3f654e940 check for duplicates should not itself assert.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Idac84099ef3f857367ee508a5e64bb2297b0e451
2022-06-16 14:00:00 +01:00
Michael Meeks 25de4d898a Elide duplicate tiles in tilecombine at the perimiter of coolwsd.
Needs a run-time check to avoid breaking concurrency assumption
during compression.

Change-Id: Icc959693e19b3506497eb1aa198477445085aeb8
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-15 18:34:58 +01:00
Michael Meeks 4478d2b083 Delta: add checks for bad memory usage across threads.
Change-Id: I09f5ad5b0af44399f92ccc0b62056172f1a0b220
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-10 10:10:05 +01:00
Michael Meeks c130231379 deltas: track, transmit and cache deltas (disabled for now)
Squashed from feature/deltas-expanded.

TileCache changes:
    + add montonic sequence (wid) numbers to TileData
    + account for sizes of TileData with multiple blobs
    + simplify saving and notifying of tiles

Sends updates (via appendChanges) based on the sequence the
right mix of keyframes and/or deltas required as a single
message, and parse and apply those on the JS side.

We continue to use PNG for slide previews and dialogs,
but remove PngCache - used by document tiles only.

Annotates delta: properly as a binary package for the websocket.

Distinguishes between deltas and keyframes we get from
the Kit based on an initial un-compressed prefix
character which we then discard.

kit can be forced to render a keyframe by oldWid=0

Track invalidity on tiles themselves - to keep the keyframe around.

    We need to be able to track that a tile is invalid, and so subscribe
    to the updated version as/when it is ready - but we also want to
    store the keyframe underneath any deltas.

force rendering of a keyframe for an empty slot in the TileCache.

force tile sequence to be zero for combinedtiles - so the client can
always request standalone tiles with explicit combinedtiles, or tile
requests.

move Blob to Common.hpp

use zero size for un-changed tiles.

remove obsolete render-id, and color deltas in debug mode.

cleanup unit tests for non-png tile results.

Change-Id: I987f84ac4e58004758a243c233b19a6f0d60f8c2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-24 22:16:58 +01:00
Michael Meeks c0cd95b8fb delta: document ids decorating previews.
Change-Id: I2f6ade6c2de962c24f7b1a10c57aeb065b62e679
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 11:48:33 +01:00
Ashod Nakashian 480fb7b931 wsd: move tokenizer helpers into StringVector
In an attempt to reduce the size of Util.{c,h}pp
which has grown to contain all sorts of unrelated
helpers, we move StringVector helpers into
the StringVector.{c,h}pp files.

This makes the code better organized.

Change-Id: I152f341606807ae66253415b951bc9f89b09df57
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Andras Timar f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Miklos Vajna d3c9e07ff3 StringVector: add a way to get a string-number pair out of this ...
... without copying the token.

And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I0dcf2eb26c93254cdc6a1c11f9708daf213a825d
2021-04-27 15:31:21 +02:00
Miklos Vajna c11f0e5708 StringVector: add a way to get a number out of this without copying the token
And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I20375d7a1c31f61662446979e4d6799fd45b49d3
2021-04-27 15:31:21 +02:00
Ashod Nakashian cb4beaca34 wsd: avoid the using keyword and use C++ size_t
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.

Also, 'using std::size_t;' isn't a great practice,
so removed.

This is not exhaustive, just some low-hanging cases.

Change-Id: I85a36b6fd1acd204274b1869de9bcb94c8b3cf13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 15:41:41 -05:00
Andras Timar 0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Ashod Nakashian 999df3fffb wsd: hashmaps have better data locality
They are especially efficient for small lookups.

Change-Id: Ia005f40127cf222debe185515fc45cd92b8ae752
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100413
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-08-10 16:00:27 +02:00
Michael Meeks 1061ac90ce TileCache: cleanup debug, propagate now more helpfully & fix staleness.
Stale tiles were still being counted, unhelpfully. Avoid doing lots
of ::now() calls, and yet detect this.

Change-Id: Ib1e4b2f1968c1994849bb23ec54e28f6706230ee
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100347
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-08-07 20:01:30 +02:00
Ashod Nakashian aba09e165b wsd: improved TileCache
* Excised TileCacheDesc to improve performance and simplify code.
* clang-tidy suggestions and auto-rewrite fixes.
* Const-correctness.
* Inlined and improved a couple of trivial functions (that are called
often).
* Reduced some logs from INF to DBG as they are only meaningful to devs.

Change-Id: I1c4eb8c63da49aa061afbf3eb68cae23d4d5e7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98661
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-07-14 15:35:20 +02:00
Ashod Nakashian d2d0492245 wsd: move LOOLProtocol::tokenize to Util::tokenize
The tokenizer(s) are more generic than the protocol
logic, and are used from contexts that don't involve
the protocol as such.

Change-Id: Ie8c256bf11a91e466bff794021f41603c9596a7f
2020-06-02 18:03:36 +01:00
Ashod Nakashian 224ef08c7f wsd: single-char string literals -> char
More readable and typically more efficient.

Change-Id: I9bd5bfc91f4ac255bb8ae0987708fb8b56b398f8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95285
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-06-02 01:31:26 +02:00
Tor Lillqvist 4eb598711c Use #pragma once
LibreOffice core uses that, too, and we support an even more
restricted set of compilers.

Change-Id: I0d0e2c8608e323eb5ef0f35ee8c46d02ab49a745
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92467
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-04-18 15:00:18 +02:00
Miklos Vajna 547f9ea731 Rework StringVector to have a single underlying string
This is meant to reduce lots of small allocations and instead have
pointers into the single string for the various tokens instead.

This has a few requirements, though:

1) It's no longer OK to modify the tokens, changing their length would
invalidate the start/length of other tokens. Rework
DocumentBroker::load() to avoid such mutation.

2) The iterators no longer expose zero-terminated strings, so
Poco::cat() doesn't work anymore: add an own cat() instead and use that
in e.g. ChildSession. The own cat() has the benefit that it won't read
past the end of the array if the begin index is out of bounds to add
more safety.

(This nicely works towards killing Poco usage in general.)

3) If zero-terminated strings for all individual tokens is needed, a
copy has to be made, as done in spawnProcess().

(For all of these requirements, the build fails if there are problems.)

Change-Id: Iea40e4400e630b2d669f5c72aea85cb40edf9a2c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89711
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-02-28 18:31:37 +01:00
Miklos Vajna b8bd1990aa Rework LOOLProtocol::tokenize() to return a StringVector object
The bulk of this commit just changes std::vector<std::string> to
StringVector when we deal with tokens from a websocket message.

The less boring part of it is the new StringVector class, which is a
wrapper around std::vector<std::string>, and provides the same API,
except that operator[] returns a string, not a string&, and this allows
returning an empty string in case that prevents reading past the end of
the underlying array.

This means in case client code forgets to check size() before invoking
operator[], we don't crash. (See the ~3 previous commits which fixed
such crashes.)

Later the ctor could be changed to take a single underlying string to
avoid lots of tiny allocations, that's not yet done in this commit.

Change-Id: I8a6082143a8ac0b65824f574b32104d7889c184f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89687
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-28 16:07:56 +01:00
Pranam Lashkari a6b0e5b827 killpoco: removed StringTokenizer from wsd directory
removed use of Poco::StringTokenizer from the wsd directory using LOOLProtocol::tokenize and std::vecor<std::string>

Change-Id: Ic50b4d4d71d4ffd005aacf6aef0ed2bfde66d40d
Reviewed-on: https://gerrit.libreoffice.org/82569
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2019-11-13 09:51:04 +01:00
mert 86489d3dcd Include normalizedViewId to TileCache
Change-Id: Ib23afa023d79189f7fd7aca8b5b0e198c3011fbc
2019-10-15 18:13:03 +03:00
mert 2ee14aa148 Extend TileDesc with normalizedViewId
Change-Id: I92046106e346289240884632d6ec6e0da7b8eabb
2019-10-15 18:13:03 +03:00
Michael Meeks f2c6facb29 Don't combine tiles a long way from each other.
We currently combine only horizontally, but ctrl-right arrow in
calc can throw us to the other side of the sheet, creating a very
large area to re-render.

Change-Id: I7125ab815e3de1296b3af32632626005eeee0ec9
2019-07-26 10:12:00 +01:00
Michael Meeks 8172885f74 PNG compression a bottleneck: thread it to accelerate things.
Also have a separate hash <-> wid cache to avoid re-rendering
older tiles as/when we see them.

Change-Id: I238fe6701a1d1cb486473c67faba8c56e9c98dcb
2019-05-02 22:36:52 +01:00
Ashod Nakashian c7ac68e8e3 wsd: tile serializer now supports adding a suffix
Moves appending tokens into the serializer and
avoids making extra copies of itself.

Change-Id: I62d374e69d9c4a55643ea20cb5f8c2b9c75c88c5
Reviewed-on: https://gerrit.libreoffice.org/71022
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-04-23 03:01:30 +02:00
Michael Meeks 2871653bf4 Simplify legacy single tile rendering code-path.
Remove redundant _id member from TileCombined, add constructor
from TileDesc, and use it to shrink the code.

Change-Id: Idc0ded63166ed350ab81b07e191b7a60d4407cd4
2019-04-19 23:51:26 +01:00
Michael Meeks 6634d3b3e9 TileCache: key almost everything on TileDesc instead of string names.
Saves lots of string construction and storage, simplifies lots of code.

Store the more exotic font-caching bits etc. in a separate store: we
should also pre-render these really and share them.

Change-Id: Icaeff8fd72f52d7215c06a687b1e39cfb7631503
2019-03-05 06:58:50 +01:00
Michael Meeks af31537a2a Expose tile-id generation to unit tests.
Change-Id: Ie56967c82192f3983ac13d53fd73346f25e6c840
2019-02-13 18:24:36 +01:00
Miklos Vajna 1dde430bcf wsd: spell out non-trivial autos to improve readability
Change-Id: I0e1f169fc39e5c722704e1cae487147d929f7350
2018-02-07 10:18:12 +01:00
Michael Meeks 78398d4482 Move the Delta generator out into its own file.
Change-Id: I7f7553c292970b1a52879b6d6c14e67172022310
2017-11-22 15:55:03 +00:00
Michael Meeks 73a87493f0 Use WireIds instead of long hashes to identify tiles efficiently.
Changes protocol to use 'wid' instead of 'hash' everywhere. Wire-ids
are monotonically increasing integers that can be mapped to hash
values for all of the hash values and tiles we cache internally.

Change-Id: Ibcb25817bab0f453e93d52a6f99d3ff65059e47d
2017-06-20 21:49:44 +01:00
Jan Holesovsky 3c9f4e1e1f Deduplicate & remove obsolete invalidations from the queue.
There's no point in trying to paint something we know will be obsolete anyway.

Change-Id: I14f61f389b114f2cda1f97e5223b31fa2f01b06c
2017-01-26 11:49:29 +01:00
Ashod Nakashian 25be7f0ab6 wsd: use own tokenizer
Change-Id: Ia6e58767e3a138d086d4e0ae287782d3ed558076
Reviewed-on: https://gerrit.libreoffice.org/33418
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:37:21 +00:00
Tor Lillqvist bc19f90dd4 Don't send a tile that hasn't changed even if client asks for it
The server tells the client the hash of each tile it sends (calculated
from the contents of the tile, not its PNG encoding). When the client
asks for a tile to be refreshed, it tells the server what the hash of
the existing tile is. If the server notices that the tile contents
hasn't actually changed, it doesn't PNG encode it and doesn't send it
to the client.

The intent is that this will reduce load on the server and also avoid
unnecessary tile traffic.

Change-Id: Ia06ca68655ea984ed4319f24f4470afda322eccf
2017-01-11 23:25:21 +02:00
Ashod Nakashian dfcada64b8 wsd: tilecombine now includes the versions of the tiles
Previously tilecombine had its own version, which is
nonesensical, since it's not really a tile.

Now it passes the version to the tiles when
parsing and serializes version per-tile.

Change-Id: I5db8d94880431e3d2a40b6787c6fe51a05771305
Reviewed-on: https://gerrit.libreoffice.org/32633
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:09:05 +00:00