Lazy DEALER creation: defer snapshot sockets until first subscribe#12
Merged
Conversation
DEALER sockets are no longer created at peer discovery time. They are created lazily when bacaro_subscribe is called, or at discovery time only if subscriptions already exist. Pure publishers (never subscribe) now create zero DEALER sockets. At device boot with N processes starting simultaneously, processes that haven't subscribed yet only pay for zmq_connect on the shared SUB socket — no DEALER creation, no snapshot requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bacaro_subscribecall via the newdiscovery_ensure_dealerhelperPeerInfogains arep_endpointfield so the endpoint string is available when the DEALER is eventually createdclose_peerhandles a nulldealer_sockgracefullyWhy
On a device with 30+ processes, every peer used to open a DEALER socket to every other peer immediately at discovery — even if neither side ever exchanged a snapshot. This causes a boot storm of N² socket setups and snapshot requests that return empty. The lazy approach means only processes that actually subscribe ever pay the DEALER cost.
Test plan
ctest)bacaro_subscribe) holds zero DEALER sockets after discoverybacaro_subscribeand receives snapshot correctly