pub fn compile(
relation: &AudioRelation,
session_of: &BTreeMap<ConnectionId, SessionId>,
since: &BTreeMap<SessionId, u64>,
silence: &Silence,
) -> AudioRoutingExpand description
Compile the declared relation into the table the voice plane reads.
session_of resolves a connection to the session it is rendered under.
Connections with no rendered user are dropped from the table: a sender nobody
can see is a sender whose audio the client would discard (guide 1.2), and a
receiver with no session has nothing to deliver to.
since carries the version each session first appeared at, threaded through
from the shard so it survives recompilation.
silence removes muted senders and deafened receivers before any route is
written down, rather than after: a muted speaker in a domain of fifty costs
nothing at all here, where filtering the finished table would cost the fifty
routes it should never have had.
§Cost
The compiled table is quadratic in a domain’s size by construction: a
full mesh of M members really does have M·(M-1) directed routes, and no
representation of an adjacency list avoids writing them down. What this
avoids is doing so through an ordered set: the members are resolved once per
domain and the receiver lists are appended to directly, so the cost is a
quadratic number of Vec pushes rather than of tree insertions. That is the
difference between microseconds and tens of milliseconds at 500 connections.