Skip to content

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

Open
Narasimha-sc wants to merge 2 commits into
masterfrom
nd/index-active-sub-conns
Open

Narasimha-sc wants to merge 2 commits into
masterfrom
nd/index-active-sub-conns

Conversation

@Narasimha-sc

Copy link
Copy Markdown
Collaborator

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.

… all subscriptions per batch

(cherry picked from commit bae057286d9675bae9a8cf1999f319b25517eda5)

This branch has not been deployed

No deployments
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