Skip to content

agent: index connections with active subscriptions instead of folding all subscriptions per batch - #1979

Closed
Narasimha-sc wants to merge 3 commits into
simplex-chat:masterfrom
Narasimha-sc:nd/index-active-sub-conns
Closed

Narasimha-sc wants to merge 3 commits into
simplex-chat:masterfrom
Narasimha-sc:nd/index-active-sub-conns

Conversation

@Narasimha-sc

Copy link
Copy Markdown

Resubscribing a session rebuilds a Set ConnId covering all of that session's active subscriptions, once per batch, just to answer "was this connection already subscribed" for at most subsBatchSize connections.

Since activeSubs grows as the resubscription proceeds, resubscribing N queues in one session costs on the order of N²/2700 traversals and allocates a set of up to N elements per batch — tens of MB of short-lived allocation per session, repeated on every network change, which under the non-moving collector shows up as resident memory rather than only CPU.

SessSubs now keeps activeConns :: TMap ConnId Int in sync with activeSubs (counted, since a connection can hold several queues), maintained at each of the five mutation sites. Behaviour is unchanged. Plan in plans/2026-09-26-index-active-sub-conns.md.


Moved from #1884 (head branch moved to fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant