Skip to content

feat(iroh)!: expose batch datagram send/recv APIs - #4547

Merged
ramfox merged 5 commits into
mainfrom
ifdario/datagram_batching
Sep 25, 2026
Merged

ramfox merged 5 commits into
mainfrom
ifdario/datagram_batching

Conversation

@ramfox

@ramfox ramfox commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Mirroring PR #4383

We want this PR merged but the original author is not responding to comments. @ifdario's commits and contributions have been preserved.

This description needs to be updated before merging.

Description

Expose the new noq batch datagram APIs through iroh's Connection wrapper so downstream crates (e.g. rayfish) can amortize the per-datagram connection-mutex cost, which is the dominant overhead at high pps for a mesh VPN forwarding bursts of TUN packets.

  • Connection::send_datagrams / read_datagrams delegate to noq::Connection.
  • Re-export ReadDatagrams and SendMany through endpoint::quic and the public endpoint surface (required by the crate's unreachable_pub lint).

Depends on the noq PR that adds Connection::send_datagrams / read_datagrams and DatagramState::recv_many / Datagrams::send_many. This branch should not merge until that noq release is published and the [patch.crates-io] override (see below) is removed.

Breaking Changes

None. All additions are additive methods and types. Existing send_datagram / read_datagram / send_datagram_wait are unchanged.

Notes & open questions

  • This branch currently carries a [patch.crates-io] override in the workspace Cargo.toml pointing noq / noq-proto / noq-udp at a local fork (../noq) so iroh can see the new APIs during development. This MUST be removed before merge, which requires the noq batch-API PR to be merged and a new noq release published to crates.io first. Leaving the patch in would break CI for anyone without the local ../noq checkout.
  • The noq dependency version in iroh/Cargo.toml is not yet bumped; a follow-up commit will bump noq (and noq-proto / noq-udp) to the released version that contains the batch APIs, and remove the patch, in the same change.
  • No new tests in iroh itself. The underlying APIs are tested in noq; iroh's wrappers are thin passthroughs, so the existing iroh datagram tests continue to exercise the single-datagram path. Adding an iroh-level integration test for the batch passthrough is possible but deferred to avoid duplication.
  • No benchmark delta. iroh's internals do not use the batch APIs yet, so iroh's own performance is unchanged. The win is realized by downstream callers that batch (e.g. rayfish's TUN read loop). Measuring that is left to the downstream caller.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant. (deferred, see Notes)
  • All breaking changes documented. (none)

ifdario and others added 4 commits July 1, 2026 08:42
Add thin passthroughs to the underlying noq batch APIs so downstream
crates (e.g. rayfish) can amortize the per-datagram connection-mutex
cost, which is the dominant overhead at high pps for a mesh VPN
forwarding bursts of TUN packets.

- Connection::send_datagrams / read_datagrams delegate to noq::Connection.
- Re-export ReadDatagrams and SendMany through endpoint::quic and the
  public endpoint surface (required by the crate's unreachable_pub lint).
- Add [patch.crates-io] pointing noq/noq-proto/noq-udp at the local fork
  (../noq) so iroh builds against the rayfish noq with the batch APIs.
  This is a workspace-local dev override; published iroh still resolves
  to noq 1.0.1 from crates.io.
Follow the noq rename to read_many_datagrams / send_many_datagrams and
the slice-based signatures.
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4547/docs/iroh/

Last updated: 2026-09-24T23:51:59Z

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 75ec13a

@n0bot n0bot Bot added this to iroh Sep 22, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Sep 22, 2026
@ifdario

ifdario commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

LGTM

@ramfox
ramfox force-pushed the ifdario/datagram_batching branch from b3935f0 to e1a9c3f Compare September 24, 2026 23:50
@ramfox
ramfox merged commit a9c194f into main Sep 25, 2026
23 of 41 checks passed
@ramfox
ramfox deleted the ifdario/datagram_batching branch September 25, 2026 00:03
@flub

flub commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

This description needs to be updated before merging.

oops...

Comment thread iroh/src/endpoint/quic.rs
//! to limit or expand how those structs are used in iroh. By encapsulating them
//! we can ensure the functionality needed to make iroh work.

use std::{path::Path, sync::Arc, time::Duration};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened here? If Path is needed unconditionally then why is the cfg left blank below. What does the cfg actually apply to now?

gsnaiper pushed a commit to gsnaiper/iroh that referenced this pull request Oct 8, 2026
Expose the new `noq` batch datagram APIs through iroh's `Connection`.

Downstream crates can amortize the per-datagram connection-mutex cost, which is the dominant overhead at
high PPS for a mesh VPN forwarding bursts of TUN packets.

`Connection::send_many_datagrams` and `Connection::read_many_datagrams` delegate to `noq::Connection`.

Re-export `ReadManyDatagrams` through `endpoint::quic` to ensure we have no unreachable structs in our public API.

Co-authored-by: Dario <dario@rayfish.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants