apple / swift-distributed-actors

Peer-to-peer cluster implementation for Swift Distributed Actors
https://apple.github.io/swift-distributed-actors/
Apache License 2.0
597 stars 56 forks source link

Whom/When to call deltaCRDT.resetDelta()? #213

Closed yim-lee closed 3 years ago

yim-lee commented 5 years ago

We had an outstanding TODO and the topic was brought up again in https://github.com/apple/swift-distributed-actors/pull/210.

resetDelta should be called some time after the delta CRDT has propagated its changes:

Some things to keep in mind:

One approach might be:

  1. Local replicator tells local ActorOwned CRDT to resetDelta after successful direct replication
  2. Local replicator calls resetDelta on its copy of CRDT after successful gossip

More thoughts in https://github.com/apple/swift-distributed-actors/pull/210#issuecomment-546013992

ktoso commented 4 years ago

I think I know how we'll tackle this thanks to recent CRDT Gossip Replicator work.

Notes:

General idea... More digging soon

yim-lee commented 4 years ago

direct local writes therefore could perhaps then be implemented as "write the specific delta that this write has caused"

Right, I think this echoes with the original thinking as well:

Direct replication sends changes of CRDT belonging to a specific owner to other replicators in the cluster. It does NOT send the delta of local replicator's copy of the CRDT.


whenever we gossip to a target, we take as many deltas as we have stored and we know the target has not seen them yet

we can resetDelta when we hand over the delta to the gossiper I believe;

👍 I guess this means gossip sends a batch of deltas (which is the behavior we want) and not after every single delta?

ktoso commented 4 years ago

👍 I guess this means gossip sends a batch of deltas (which is the behavior we want) and not after every single delta?

Yup, we get batching there :-)