You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[pkgs/id] GraphFrontier re-resolves the whole store on every gated message #13043
GraphFrontier::is_authorized runs on every inbound relay message (pkgs/id/crates/id-sync/src/graph_frontier.rs:71-81) via RelayGate::decide (pkgs/id/crates/id-sync/src/relay_gate.rs:233-236).
Each call runs EventStore::roster (pkgs/id/crates/id-events/src/event_store/mod.rs:554-566), which calls:
resolve::load (pkgs/id/crates/id-events/src/event_store/resolve.rs:568-611) — iterates and decodes every stored event plus its action/device-op rows, plus all fork rows and proof headers;
resolve::resolve — full causal fold over the loaded store;
resolve::roster_of (resolve.rs:676) — projects one group's roster from the full resolution.
So per-message gate cost is O(store size): N stored events decoded + folded for every relay message, even when group membership has not changed. SharedEventStore::read (id-store store_traits.rs) is a plain lock with no memoization, so there is no caching layer underneath.
Why this matters
The relay gate sits on the hot path for every message a relay receives. As the store grows (more groups, more history), each authorization check gets slower even for steady-state traffic in one small group. Membership changes are rare relative to message volume, so re-resolving the whole graph per message repeats work whose answer almost always hasn't changed.
Acceptance
Relay-gate authorization cost per message is bounded by group/roster size, not by total store size (e.g. per-group roster cache, ingest-generation invalidation, or an incremental membership projection).
A regression test ingests N unrelated events and asserts is_authorized latency/message cost does not grow with N (or asserts roster reads hit the cache and miss only on ingest).
Existing frontier tests still pass: cargo test -p id-sync --lib graph_frontier, including removal-takes-effect semantics (a removal in the store is refused at the gate as soon as ingested).
Fix shape (suggestion, not prescription)
Cache group -> (roster, store generation) inside GraphFrontier (or below EventStore::roster), bump the generation on ingest, and serve cache hits without load+resolve;
or expose an incremental membership projection the frontier can read directly.
Scope is the caching follow-up only. The remaining end-to-end bridge re-check named on #3796 stays separate.
Pickup (lane xaltha): working this now. Branch xaltha/13043-graphfrontier-cache from current main. Plan: cache the per-group roster inside GraphFrontier keyed by an ingest generation so is_authorized stops re-running load+resolve per gated message, with a regression test showing roster reads hit the cache and a removal still takes effect as soon as it is ingested.
Activity
developing-today commentedon Nov 23, 2026
CODE-4759
dezren39 commentedon Nov 23, 2026
Pickup (lane xaltha): working this now. Branch
xaltha/13043-graphfrontier-cachefrom current main. Plan: cache the per-group roster insideGraphFrontierkeyed by an ingest generation sois_authorizedstops re-runningload+resolveper gated message, with a regression test showing roster reads hit the cache and a removal still takes effect as soon as it is ingested.id-events: memoize EventStore::roster per store generation (#13043)