Skip to content

smp-server: fix service subscription memory leak#1827

Merged
epoberezkin merged 1 commit into
masterfrom
sh/fix-service-sub-leak
Jul 10, 2026
Merged

smp-server: fix service subscription memory leak#1827
epoberezkin merged 1 commit into
masterfrom
sh/fix-service-sub-leak

Conversation

@shumvgolove

Copy link
Copy Markdown
Collaborator

Service subscription counters (totalServiceSubs, serviceSubsCount, ntfServiceSubsCount) are TVar (Int64, IdsHash). modifyTVar' only forces the pair to WHNF, so n +/- n' and idsHash <> idsHash' stay unevaluated and accumulate an unbounded thunk chain under subscription and delivery churn (the IdsHash chain also retains a bytestring per update) - a space leak proportional to the number of updates.

Force both components in addServiceSubs/subtractServiceSubs. Verified with the load bench: svc churn drops from +5.4 KiB/iter (linear) to flat.

Service subscription counters (totalServiceSubs, serviceSubsCount,
ntfServiceSubsCount) are TVar (Int64, IdsHash). modifyTVar' only forces
the pair to WHNF, so `n +/- n'` and `idsHash <> idsHash'` stay
unevaluated and accumulate an unbounded thunk chain under subscription
and delivery churn (the IdsHash chain also retains a bytestring per
update) - a space leak proportional to the number of updates.

Force both components in addServiceSubs/subtractServiceSubs. Verified
with the load bench: svc churn drops from +5.4 KiB/iter (linear) to flat.
@epoberezkin epoberezkin merged commit 43e46dd into master Jul 10, 2026
1 of 6 checks passed
@epoberezkin epoberezkin deleted the sh/fix-service-sub-leak branch July 10, 2026 08:00
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.

2 participants