Skip to content

Shared SUB socket: O(1) fd usage for live updates#10

Merged
bricke merged 4 commits into
mainfrom
shared-sub-socket
Mar 27, 2026
Merged

Shared SUB socket: O(1) fd usage for live updates#10
bricke merged 4 commits into
mainfrom
shared-sub-socket

Conversation

@bricke
Copy link
Copy Markdown
Owner

@bricke bricke commented Mar 26, 2026

Summary

  • 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 kept for the snapshot protocol (ZMQ DEALER round-robins, can't share)
  • Scalability sweet spot moves from 50–100 to 50–200 processes with zero tuning

Wire format change (breaking)

v1: [topic][header][payload]              — 3 frames
v2: [topic][publisher][header][payload]   — 4 frames

Test plan

  • All 7 test suites pass (wire, cache, lifecycle, discovery, snapshot, pubsub, get_domain)
  • test_wire updated for 4-frame format and publisher roundtrip
  • test_pubsub "multiple publishers" validates correct attribution via shared socket
  • test_snapshot validates publisher identity survives snapshot protocol
  • Architecture and edge-cases docs updated

bricke added 4 commits March 25, 2026 22:23
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.
@bricke bricke merged commit 324cc3f into main Mar 27, 2026
4 checks passed
bricke added a commit that referenced this pull request Mar 27, 2026
@bricke bricke deleted the shared-sub-socket branch March 27, 2026 02:10
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