Skip to content

[Tracking] Make inbound/convergence processing incremental, bounded, and non-blocking #380

Description

@erskingardner

Summary

A large cluster of issues are all symptoms of one missing contract: the inbound message / convergence pipeline is not designed to do incremental, bounded, non-blocking work. Instead, per-event and per-pass code recomputes derived state from scratch, runs unbounded queries, blocks the critical path on long I/O, and — worse — computes the same logical quantity (ordering keys, derived counts, parsed routes) inconsistently in more than one place, which turns a performance smell into data loss.

This issue tracks one pipeline contract: define what state the receive/convergence path maintains incrementally, what work may run on the per-event critical section, and which derived quantities have a single canonical source.

Child issues / concrete symptoms

Redundant recomputation (cost):

Head-of-line blocking (critical-path I/O):

Consistency failures (same quantity computed two ways → data loss / liveness gaps):

Proposed unifying solution

Define one inbound/convergence processing contract with three guarantees:

Acceptance criteria

  • The architecture docs describe the inbound/convergence pipeline as incremental + bounded + non-blocking, and name the canonical derived-state owners.
  • Lag recovery replays a bounded, watermark-keyed window; no limit: None history query remains on the hot path.
  • Convergence replay does not re-replay shared path prefixes or re-serialize the full seen set per pass (benchmarks or complexity tests demonstrate sub-quadratic behavior).
  • Relay-URL parsing, unread/mention counts, and per-message directory/group/profile lookups are computed once per window, not per endpoint/row/event.
  • Relay I/O, full resync, and idempotency fsync no longer execute on the per-event/per-command critical section; a test or trace shows independent events are not head-of-line blocked.
  • The store ordering key and the lag-recovery watermark tie-break share one definition, with a regression test for the same-second case in Broadcast-lag recovery watermark tie-break disagrees with store ordering — same-second live messages can be permanently dropped #439.
  • Deferred-startup replay schedules buffered convergence groups before entering the steady-state loop (Relay subscribe is serial + all-or-nothing; every surgical fix regresses the wake-delivery test #637 regression test).

Why this should be tracked holistically

Fixed individually these read as a dozen unrelated perf nits — but #439 and #435 prove the same root cause also drops messages and strands convergence work. The unifying fix is not "optimize each query"; it is to give the receive/convergence path one contract (incremental, bounded, off-critical-path, single-source-of-truth for shared quantities) so new pipeline code inherits the property instead of reintroducing the next variant.

Additional child issues (2026-06-30 review pass)


Generated by Claude Code

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions