-
Notifications
You must be signed in to change notification settings - Fork 11
Description
In some usage patterns (e.g. P2P), users share states back and forth to bring each other up-to-date. Currently, each user needs to send their whole saved state, even if they actually only need to share a few updates. I believe this is okay for now because saved states are usually small (10s of KB), but it would be nice to allow "incremental" saves that optimize this.
Specifically, CRuntime.save could input a vector clock or existing saved state, then return a saved state that includes only the delta on top of that. Collabs would receive this input in some (generic) metadata field passed down the tree of Collab.save calls.
When I tried this before, I gave up because finding the delta for deletions is hard: given only the base vector clock, you don't know which elements have been deleted since then, so you need to either send the IDs of all present elements or store tombstones. I now think that the former is okay: although { all IDs } does not asymptotically improve over { all elements }, it should be a large constant-factor improvement. We can also avoid this problem when we're given a whole saved state as the base instead of just a vector clock.
Other CRDT libraries' analogs: Yjs encodedTargetStateVector; Automerge saveIncremental (?).