Shared SUB socket: O(1) fd usage for live updates#10
Merged
Conversation
Replace per-peer SUB sockets with a single shared SUB socket that calls zmq_connect/zmq_disconnect as peers come and go. Publisher identity moves from socket-inference to an explicit wire frame (wire version 1 → 2, 3 frames → 4). Per-peer DEALER sockets are kept for the snapshot protocol since ZMQ DEALER round-robins outgoing messages. This drops per-process fd usage for SUB from O(N) to O(1).
Reflect the shared SUB socket design in architecture.md: wire format v2 (4 frames), shared socket discovery, updated dispatch table, and revised internal structs. Add scalability table to edge-cases.md with the improved fd numbers.
The test assumed discovery + initial snapshot would complete within a single 20ms sleep + one dispatch round. Pump until the initial sensors snapshot arrives before subscribing to network mid-life.
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
zmq_connect/zmq_disconnectas peers come and goWire format change (breaking)
Test plan
test_wireupdated for 4-frame format and publisher roundtriptest_pubsub"multiple publishers" validates correct attribution via shared sockettest_snapshotvalidates publisher identity survives snapshot protocol