Module compose

Module compose 

Source
Expand description

Composing one connection’s transition out of the shared delta.

This is the heart of the runtime, and it is about fifteen lines:

let shared  = filter(journal.replay(cursor, head), see);
let private = plan_elements(&overlay_sent, &overlay_new);
let mut ops = splice(shared, private);
collapse(&mut ops);

§What must not be done instead

diff(overlay + shared, committed) is the honest formulation and it is always correct - and it costs O(V) per connection, so O(N·W) overall. That is precisely the quadratic this design exists to escape. Composition costs O(|D|) + O(|overlay|) + O(|ops|).

REF: docs/design/guide-implementation.md 6

Functions§

collapse
Drop every removal of an element that is also added in the same transition.
filter
Keep the operations this connection can see.
splice
Insert the overlay’s operations inside the shared phases.