Commit graph

87 commits

Author SHA1 Message Date
Michael Meeks
6bce292c44 Send intermediate tiles back even when we they are older.
Should improve interactivity and avoid jerky feedback.
2016-09-01 21:18:38 +01:00
Ashod Nakashian
16605b9289 Revert "loolwsd: canceltiles re-designed using tilecache instead of queue"
This reverts commit 571ff06906.

Change-Id: Icf9caeafc640b815f64211f240cfdac8e91694a1
Reviewed-on: https://gerrit.libreoffice.org/28595
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 12:37:47 +00:00
Ashod Nakashian
77a693c353 Revert "loolwsd: remove tile queue and simplify tile response"
This reverts commit 59eaacd2f8.

Change-Id: Ieba9bbaaa6406e3e685b46ce12a44a0766127815
Reviewed-on: https://gerrit.libreoffice.org/28594
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 12:37:38 +00:00
Ashod Nakashian
59eaacd2f8 loolwsd: remove tile queue and simplify tile response
Tile queue was used to process canceltiles commands.
Since those are handled by TileCache, there is no need
for queues and the threads that pump them.

But because these queues were also used to buffer between
WSD internals and clients, such that a slow client wouldn't
block WSD while sending back tiles, it is necessary
to reword that logic.
In subsequent commits that will change as well.

With this change not only do we save a thread per client,
but we also reduce latency of tile, and improve typing
responsiveness, by almost 3x or more! Latencies are
down to ~15ms from almost 50ms.

Change-Id: I9bb5856efed28caea9d4e6f94f77b093779e5241
Reviewed-on: https://gerrit.libreoffice.org/28575
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 03:59:31 +00:00
Ashod Nakashian
571ff06906 loolwsd: canceltiles re-designed using tilecache instead of queue
Change-Id: I4b9ba91ee08bc9dd8d27df275e303f5517d9740c
Reviewed-on: https://gerrit.libreoffice.org/28526
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-31 04:44:56 +00:00
Ashod Nakashian
3af0d69d22 loolwsd: isTileBeingRenderedIfSoSubscribe -> subscribeToTileRendering
Simpler yet descriptive function name and better logging.

Change-Id: Ic903197d5772b7994ffa8136cfae771deee3a24a
Reviewed-on: https://gerrit.libreoffice.org/28291
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-22 04:54:29 +00:00
Ashod Nakashian
08909b2a3d loolwsd: doxygen comments added to all classes
Change-Id: Ia485c2dcec20a6840d46836a61f75a8e7e8762ed
Reviewed-on: https://gerrit.libreoffice.org/28128
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-15 03:12:31 +00:00
Pranav Kant
d18379adce loolwsd: Show only abbreviated message when reading from cache
Change-Id: I6d5c8984010e2917b9069df6ee3b0a28c678b297
2016-07-11 11:24:19 +05:30
Pranav Kant
0b8e9dedaf loolwsd: Print abbreviated message while saving to TileCache
Change-Id: I1f77062466e3672ce742b6a46e3c39b35ce70f31
2016-07-01 20:29:19 +05:30
Ashod Nakashian
9dbc213337 loolwsd: log tile rendering rountrip time
Change-Id: Ib97e196d6de053e6b79ea448296003f30a5949b5
Reviewed-on: https://gerrit.libreoffice.org/25347
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:58:25 +00:00
Ashod Nakashian
157386e3bc loolwsd: process tiles under the cursor with priority
Change-Id: I7993ee049c5c0835cae588ff54163f135c4f8b02
Reviewed-on: https://gerrit.libreoffice.org/25345
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:57:16 +00:00
Ashod Nakashian
6e54fd05f9 loolwsd: merge saveTile and notifyAndRemoveSubscribers
Change-Id: I8282604c02a9fd1a7a1e2a5df29e2f84fca151a6
Reviewed-on: https://gerrit.libreoffice.org/25344
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:54:55 +00:00
Ashod Nakashian
e5aaac7631 loolwsd: Tile versioning and fix to race conditions
Tile invalidation and painting can race with one another.

A race when the user types two characters in quick succession:
1. After the first key press, the tile is invalidated.
2. The client request the tile on receiving the invalidate.
3. TileCache doesn't find it, and adds subscription.
 A. Sometime before rendering, the second key press is received.
 B. This invalidates the very same tile.
 C. The client request the same tile.
 D. TileCache finds a subscription and ignores the new one.
4. The tile is rendered and sent back.
5. Subscription is found and the tile is forwarded to clients.
6. Subcription is removed as the request is fullfilled.
 E. The second tile is rendered and sent back.
 F. TileCache finds no subscription and the tile is dropped.

End result: Only the first character appears on the screen.

Versioning fixes the above situation by making sure that in
step 5 the subscription will show to belong to a different
(and newer version) and so the tile will be ignored.
Instead, at F the TileCache will find both subscription
and a matching version and the lastest version will always
be sent back to the client.

Change-Id: I7d7fe1407cda1908d794683c3ce4c2fd18609a2f
Reviewed-on: https://gerrit.libreoffice.org/25341
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:52:36 +00:00
Ashod Nakashian
fae850189d loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.

Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.

This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.

Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).

Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:52:54 +00:00
Ashod Nakashian
b2fa9d6f2e loolwsd: moved TileDesc into own file
Change-Id: I54162f7ebaaca51f9c52a30af1e278db212562fa
Reviewed-on: https://gerrit.libreoffice.org/25261
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:49:10 +00:00
Ashod Nakashian
b2881306f1 loolwsd: MasterProcessSession splitting: moved input queue
Change-Id: Id1c2b0f76a96ca48905d354c02a96b35ba29fadc
Reviewed-on: https://gerrit.libreoffice.org/25046
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:21:44 +00:00
Ashod Nakashian
d18bca992c loolwsd: use TileDesc instead of explicit values
Change-Id: I56ba6c4e63a495500093e7353477175d40152d11
Reviewed-on: https://gerrit.libreoffice.org/25020
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 23:00:43 +00:00
Ashod Nakashian
2b0347e391 loolwsd: new tile descriptor class to represent tiles
Change-Id: I680ea2d698a352bf3f99b37713d68c34d9502ea4
Reviewed-on: https://gerrit.libreoffice.org/25019
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 22:56:48 +00:00
Ashod Nakashian
57947dfd4d loolwsd: timeout tile requests and reissue them
Change-Id: I7dee06d905f59d73fdc9aa4e03831c5e5d16b9e3
Reviewed-on: https://gerrit.libreoffice.org/25007
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 14:33:47 +00:00
Miklos Vajna
c2fc95ac23 Drop unused using declarations
Change-Id: Iee778833781c6f00c1fb0b8fc1975acfe4fb0cd9
2016-05-10 09:14:22 +02:00
Ashod Nakashian
1643938a8e loolwsd: support the tile id param when broadcasting tiles to subscribers
Obviously this is dangerous, since the id is not part of the
subscription key (the filename) so different clients could
have different ids on the same part, but in practice I
expect this not to happen. Though that clearly depends on
how clients use the id.

Change-Id: I52a0b043c9b5e5ad1111b692e4216cc9ffec5b2b
Reviewed-on: https://gerrit.libreoffice.org/24680
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 14:23:22 +00:00
Ashod Nakashian
cd8d48e6bb loolwsd: tile logs
Change-Id: Id5c8b688c36038dc6f02ad95ad1c43412dcd2c31
Reviewed-on: https://gerrit.libreoffice.org/24668
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 02:34:13 +00:00
Ashod Nakashian
92c068541a loolwsd: -Werror=shadow
Change-Id: Ifc3c065fd7b6d20f8bad5f5a6a1b48c47bc8f1e0
Reviewed-on: https://gerrit.libreoffice.org/24649
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 11:19:38 +00:00
Ashod Nakashian
25a8b71dbb loolwsd: hoist invariant message out of loop
Change-Id: I9319518a4bbba9c24ba5c0132d89ad6a793247e8
Reviewed-on: https://gerrit.libreoffice.org/24643
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 10:37:24 +00:00
Ashod Nakashian
a240f2666f loolwsd: tile traffic is now completely centralized
WSD's DocumentBroker and Kit's Document now handle
the communication of tiles as well as all aspects
of rendering, caching, unifying requests and
distributing results etc.

Change-Id: Ie22fbaaae26b91185ee348ec7077f30430eec0f6
Reviewed-on: https://gerrit.libreoffice.org/24640
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 10:36:01 +00:00
Ashod Nakashian
6c57e9be4d loolwsd: helper to assert a lock is already taken
Change-Id: Id28f7a39a4d45ea6ad391015364467dc8ded3e66
Reviewed-on: https://gerrit.libreoffice.org/24599
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-03 00:00:13 +00:00
Ashod Nakashian
c913e8e135 loolwsd: assert when we should be called with lock acquired
Change-Id: If784dbbfe6ca687fff181f623e413e9b86d51807
Reviewed-on: https://gerrit.libreoffice.org/24580
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-02 02:53:22 +00:00
Ashod Nakashian
d16f44d7a2 loolwsd: TileCache unittest, hooks, and events
Change-Id: Id9e0539d2f920f15b0d0cb8e5924e480ed6d1e87
Reviewed-on: https://gerrit.libreoffice.org/24570
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-01 17:16:31 +00:00
Miklos Vajna
78308db763 loolwsd: remaining 'unnecessary copy' fixes
Change-Id: I138e8473a002a15aae7752136950bb905a21fb1f
2016-04-27 14:58:33 +02:00
Ashod Nakashian
5cfc7b6580 loolwsd: logging and cosmetics
Change-Id: Idb2cdc22555d237a162b58cacbfd1986f8bc7656
Reviewed-on: https://gerrit.libreoffice.org/24383
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-26 10:41:41 +00:00
Michael Meeks
e64bc95044 Further TileBeingRendered cleanup & re-factor.
Turn TileBeingRendered into an internal implementation detail.
2016-04-25 10:11:36 +01:00
Miklos Vajna
f99e2146bc TileCache: loop variable is copied but only used as const reference
Change-Id: I2f4ec5dad91abd6776095962070bd5b12021c24f
2016-04-25 09:11:59 +02:00
Michael Meeks
8f7eed639c Re-factor tile subscription logic.
Move the logic into the TileCache, simplify the API, and
internalize the lock. This should be a plain re-factor.
2016-04-23 18:03:42 +01:00
Michael Meeks
2c2504a073 Time stamp subscriptions to tile rendering. 2016-04-23 18:03:42 +01:00
Tor Lillqvist
f46855eb25 It is not a cause for warning if we are removing a file
Use info() instead. Also, only log the info if the file actually
existed and was removed. We don't want misleading noise logging about
removing files that were not there. Use std::remove() directly to
avoid unnecessary layers that just make it harder to know whether the
removal worked or not.
2016-04-22 17:50:25 +03:00
Tor Lillqvist
bff5748cd9 No need to have separate "editing" and "persistent" tile caches
All changes are supposed to be persistent. This simplifies the tile
caching code quite a lot.

The TileCache object no longer needs to keep any state whether the
document is being edited or whether it has been modified without
saving etc.

Update the modtime.txt file after saving the document. Otherwise the
tile cache would wrongly be considered invalid next time.

As a sanity check, we put a flag file 'unsaved.txt' into the cache
directory whenever we get a callback that indicates the document has
been modified, and remove it when the document is saved. If the flag
file is present when we take an existing tile cache into use, we can't
trust it.

Even after these changes, we still don't use an existing tile cache as
much (or at all?) as we could, though. The INVALIDATE_TILES EMPTY
callback that LO does early on in a conection causes us to remove all
cached tiles...
2016-04-22 17:49:39 +03:00
Michael Meeks
60ffc8aa6b Avoid tile subscription loop, and elide redundant tile subscriptions. 2016-04-22 07:58:31 +01:00
Miklos Vajna
0833a99b37 TileCache: avoid copying these for each invocation
Change-Id: Icaf84699d7f54f2f977162a040aed1f4090f680d
2016-04-22 08:39:16 +02:00
Tor Lillqvist
d446822fb3 Add some more logging for tile cache management 2016-04-21 12:42:53 +03:00
Tor Lillqvist
bf6dd4e291 Typo 2016-04-19 16:17:58 +03:00
Tor Lillqvist
d5bb373447 Improve efficiency when multiple clients of same doc ask for same tile(s)
Keep track of tiles being rendered in TileCache, and when asked to
render the same tile as is already being rendered, just "subscribe" to
the existing ongoing rendering. When a tile has been rendered and is
being sent out to clients, check if there are "subscriptions" and send
it to them, too.

One problem is that if the client that caused a tile rendering to be
initiated goes away before the rendering has completed, it will never
complete, and the subscribers are left without the tile.

Change-Id: Icca237876a0f466c29eb5bf60ffd4da3d9d68600
Reviewed-on: https://gerrit.libreoffice.org/24228
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-19 10:51:45 +00:00
Ashod Nakashian
0b4b3c73d5 loolwsd: tile cache cleanup
Change-Id: Ib2abec83fd4866c09b30507c11a809d682c2f819
Reviewed-on: https://gerrit.libreoffice.org/24100
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-15 01:08:37 +00:00
Ashod Nakashian
e5595509fd loolwsd: cosmetic cleanup
Change-Id: I02f3ab1778db462376b7563e7e8b0abeebd2e8a1
Reviewed-on: https://gerrit.libreoffice.org/24098
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-15 01:04:47 +00:00
Ashod Nakashian
3499878fae loolwsd: logging and cleanups
Change-Id: I0664be51da54d2e374808256e6598ba025f0324e
Reviewed-on: https://gerrit.libreoffice.org/23822
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-05 02:59:12 +00:00
Tor Lillqvist
7a80ca8aa1 Make use of 'using' consistent in this file 2016-04-01 18:57:07 +03:00
Tor Lillqvist
9a874e7cda Catch and ignore FileExceptions when persisting editing tiles
There is nothing that says a client has even requested any tiles, so
there might be none to persist. Don't let an exception thrown by the
DirectoryIterator propagate upwards and cause potential
issues.

Noticed the issue when testing using the 'connect' test program,
giving it input that did not request any tiles.
2016-04-01 18:57:07 +03:00
Ashod Nakashian
2ba9bddf9a loolwsd: logging improvements
Change-Id: Ie656aa9d9f19762a960f6608cdadccf3c7eee665
Reviewed-on: https://gerrit.libreoffice.org/23646
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-30 02:03:25 +00:00
Ashod Nakashian
3d2c2fde3b loolwsd: logging and misc cleanup
Change-Id: If3cea8191fe15fc752c436cd33d2a68dc2d88598
Reviewed-on: https://gerrit.libreoffice.org/23638
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-30 01:46:34 +00:00
Ashod Nakashian
b4a4c45a36 loolwsd: Storage gets last modified time and simplified TileCache construction
Change-Id: I4a7e7b941c136b59ffd7d935310d37d73ac4ec63
Reviewed-on: https://gerrit.libreoffice.org/23540
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-26 17:10:25 +00:00
Ashod Nakashian
06d2caa098 loolwsd: TileCache logging and efficient filename generator
Change-Id: Id5c524f8a3d1b7ee285b620769e3378e73148138
Reviewed-on: https://gerrit.libreoffice.org/23538
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-26 17:08:12 +00:00