When mesh router receives ProtocolGossipBroadcast traffic it attempts to relay broadcast to peers. In order to broadcast gossip recived from a source, routes.BroadcastAll() is performed on each received gossip. routes.BroadcastAll() calls peer.routes which is known to be O(n^2) operation.
As an optimization to prevent peer.routes calls, routes.lookupOrCalculate caches the calculated broadcast routes. However on topology changes routes are flushed. While this should be fine on a stable cluster, when there is constant toplogy changes cache misses can be expensive.
Following metrics (gathered as calls per second) were gathered with instrumented mesh on 150 node kubernetes cluster with weave-net using the mesh. Its not uncommon for some one to apply daemon set which results each node connecting to rest of the peers (so n^2 connection) resulting in significant topology changes. Hence misses in routes.lookupOrCalculate() resulting in calculating peer.routes on every call.
It would be desirable to prevent excessive peer.routes() calls resulting from the gossip broadcast
When mesh router receives
ProtocolGossipBroadcast
traffic it attempts to relay broadcast to peers. In order to broadcast gossip recived from a source,routes.BroadcastAll()
is performed on each received gossip.routes.BroadcastAll()
callspeer.routes
which is known to be O(n^2) operation.As an optimization to prevent
peer.routes
calls,routes.lookupOrCalculate
caches the calculated broadcast routes. However on topology changes routes are flushed. While this should be fine on a stable cluster, when there is constant toplogy changes cache misses can be expensive.Following metrics (gathered as calls per second) were gathered with instrumented mesh on 150 node kubernetes cluster with weave-net using the mesh. Its not uncommon for some one to apply daemon set which results each node connecting to rest of the peers (so n^2 connection) resulting in significant topology changes. Hence misses in
routes.lookupOrCalculate()
resulting in calculatingpeer.routes
on every call.It would be desirable to prevent excessive
peer.routes()
calls resulting from the gossip broadcast