Fix performances issues
See #20 (closed) for problem description.
Proposed solutions :
Serialization
- Delay updates to group changes and factor serialization:
- Client: onWrite() stores objects references, commit serializes and send state
- Editor: transaction is delayed :valueChanged() either
- do nothing, and a diff is made periodically
- OR creates a timer (setTimeout()) to eventually perform the transaction
iff no timer is already setup
(optionally increase delay: replace a running timer if not older than x seconds)
In both case, the transaction is skipped if nothing changed
- Send deltas instead of full state
→ already planned, probably not urgent - Optimize toJson(): update kotlinx.serialization, remove transform*(),…
→ already planned, probably too early - Perform updates/serialization in a different thread
→ overkill, would lead to communication complexity and concurrency issues
Merge
- limit the frequency of remote requests
- client: delay get request until
- previous merge completed ([opt] by n seconds)
- or previous request timed out
- client: delay get request until
- optimize RGA.merge()
- optimize lookup for existent nodes :
- assuming nodes are in the right order in the delta
(already assumed to some extent),
resume lookup right after the previous node position (using subList())
→ would reduce total cost of existence checks to one scan - OR add a Set of known nodes
→ total checks cost in O(delta size) instead of O(local size), but requires to update the Set in modifiers
- assuming nodes are in the right order in the delta
(already assumed to some extent),
resume lookup right after the previous node position (using subList())
- optimize siblings lookup:
- scan from previous node instead of beginning
- directly find first older sibling, not all siblings
- [optional] track the current path in the tree to optimize the rare case
→ harder to implement, may not be worth the effort
- optimize lookup for existent nodes :
- optimize deserialization (see Serialization / 3)