{"id":15787433,"url":"https://github.com/dunnock/ll-udp-pubsub","last_synced_at":"2025-10-31T10:15:53.365Z","repository":{"id":99985318,"uuid":"510292061","full_name":"dunnock/ll-udp-pubsub","owner":"dunnock","description":"Low latency UDP pubsub ","archived":false,"fork":false,"pushed_at":"2023-04-08T09:55:43.000Z","size":79072,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T05:27:12.312Z","etag":null,"topics":["channel","low-latency","pubsub","rust-lang","udp","volition"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dunnock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-04T09:22:45.000Z","updated_at":"2023-09-20T08:13:19.000Z","dependencies_parsed_at":"2023-05-11T10:45:35.379Z","dependency_job_id":null,"html_url":"https://github.com/dunnock/ll-udp-pubsub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Fll-udp-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Fll-udp-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Fll-udp-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Fll-udp-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dunnock","download_url":"https://codeload.github.com/dunnock/ll-udp-pubsub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243569701,"owners_count":20312483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["channel","low-latency","pubsub","rust-lang","udp","volition"],"created_at":"2024-10-04T21:20:24.287Z","updated_at":"2025-10-31T10:15:53.359Z","avatar_url":"https://github.com/dunnock.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"(c) Volition Technologies 2023\n\n# UDP pubsub channel with minimum latency\n\nExtremely low latency overhead on top of UDP (1-2 microseconds)\n\n# Publisher and subscriber\n\n\n```rust\nimpl ManagedPublisher {\n    pub fn send\u003c'r, Message: Serialize\u003e(\u0026mut self, msg: Message) -\u003e Result\u003c(), std::io::Error\u003e { .. }\n}\n```\n\n```rust\nimpl\u003cMessageHandler: Handler + Send + 'static\u003e UdpSubscriber\u003cMessageHandler\u003e {\n    pub fn spawn(\n        self,\n        bind_to_core: Option\u003cusize\u003e,\n    ) -\u003e Result\u003cUdpSubscriberHandle\u003cMessageHandler\u003e, std::io::Error\u003e { ... }\n}\n```\n\n# Usage example\n\n## Implement publisher\n\n```rust\nlet (ctl, mut publisher) = PublisherController::create(config).unwrap();\nlet handle = ctl.spawn().unwrap();\n\nlet timeout = Duration::from_micros(opts.timeout_micros);\nfor i in 0..i64::MAX {\n    publisher.send(i).unwrap();\n    std::thread::sleep(timeout);\n}\n\nhandle.shutdown().unwrap();\n```\n\n## Implement subscriber\n\n```rust\nimpl Handler for Receiver {\n    type Message = i64;\n    fn handle(\u0026mut self, msg: Packet\u003cSelf::Message\u003e, received_ts: i64) {\n        self.count.fetch_add(1, Ordering::Relaxed);\n        self.messages.push((msg.sent_ts, msg.data));\n    }\n}\n\nlet count = Arc::new(AtomicUsize::default());\nlet subscriber_config = UdpSubscriberConfig::new(opts.client_addr);\nlet receiver = Receiver { count: count.clone() };\nlet mut subscriber = UdpSubscriber::new(subscriber_config, receiver).unwrap();\nsubscriber.set_nonblocking(true).unwrap();\nlet controller_handle = subscriber.spawn_controller(opts.server_addr).unwrap();\nlet subscriber_handle = subscriber.spawn(core(1)).unwrap();\n\nfor i in 0..10 {\n    println!(\"{}\", count.load(Ordering::Relaxed));\n    std::thread::sleep(Duration::from_secs(1)).unwrap();\n}\n\ncontroller_handle.shutdown();\nsubscriber_handle.shutdown();\nlet result = subscriber_handle.shutdown().unwrap();\ndbg!(result);\n```\n\n## Other approaches worth trying\n\n- eBPF, io_uring, linux mod, unikernel and open onload(complimentary)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunnock%2Fll-udp-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdunnock%2Fll-udp-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunnock%2Fll-udp-pubsub/lists"}