-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement non-wildcard subscription management#2238
Implement non-wildcard subscription management#2238jboshoven-emporia wants to merge 1 commit intodotnet:masterfrom
Conversation
In a world where there are a ton of clients with many subscriptions that are not wildcard, it can get really expensive to loop through the entire list of subscribers. This change breaks the subscribers down into two lists, one for wildcards and one without. You can see in DispatchApplicationMessage that if there is a _simpleTopicToSessions it will be grabbed first and added to all wildcard sessions. If there are no wildcard sessions, this operation is exceedingly cheap. The rest of the change outside of this spot is pretty much just plumbing.
This change is based on this PR #2175 by AlexNik4 to try and solve this issue #2174.
This change also stops copying the hash set on publish. These sets have become copy on write and then the entire session management lock was removed at the expense of more garbage during subscribe/unsubscribe. This garbage was paid for every publish anyway.
This change is based on this PR dotnet#2175 by AlexNik4 to try and solve this issue dotnet#2174.
This change also stops copying the hash set on publish. These sets have become copy on write and then the entire session management lock was removed at the expense of more garbage during subscribe/unsubscribe. This garbage was paid for every publish anyway.
| _sessionsManagementLock.EnterReadLock(); | ||
| try | ||
| MqttSessionLists subscriberSessions; | ||
| if (_simpleTopicToSessions.TryGetValue(applicationMessage.Topic , out var matchedSimpleTopicSessions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the read that returns an iterator with a copy of the values.
|
@dotnet-policy-service agree company="Emporia Energy" |