Skip to content

WIP: conn_linux: add recvmmsg#30

Draft
nickgarlis wants to merge 1 commit into
mdlayher:mainfrom
nickgarlis:add-recvmmsg
Draft

WIP: conn_linux: add recvmmsg#30
nickgarlis wants to merge 1 commit into
mdlayher:mainfrom
nickgarlis:add-recvmmsg

Conversation

@nickgarlis

Copy link
Copy Markdown
Collaborator

Add a Recvmmsg wrapper exposing recvmmsg(2) for high-rate event-stream consumers. Integrates with the runtime poller via the existing read helper.

This is mostly an experiment at this point. The goal is to reduce syscalls when using netlink nfqueue.

Limitations:

  • linux/amd64 only. The local mmsghdr struct assumes 64-bit layout (trailing padding after Msglen).

  • No per-message sender address. Unlike unix.Recvmsg, this does not return a Sockaddr.

  • No scatter-gather per message. Each message uses exactly one iovec; callers cannot split a single message across multiple buffers.

  • Allocates five slices per call (iovs, msgs, and the three result slices). A future RecvmmsgInto variant taking caller-allocated storage would eliminate this for steady-state high-rate consumers.

  • MSG_WAITFORONE is accepted but has no effect given the nonblocking-fd + poller pattern.

Add a Recvmmsg wrapper exposing recvmmsg(2) for high-rate event-stream
consumers. Integrates with the runtime poller via the existing read
helper.

This is mostly an experiment at this point. The goal is to reduce
syscalls when using netlink nfqueue.

Limitations:

  - linux/amd64 only. The local mmsghdr struct assumes 64-bit layout
    (trailing padding after Msglen).

  - No per-message sender address. Unlike unix.Recvmsg, this does not
    return a Sockaddr.

  - No scatter-gather per message. Each message uses exactly one iovec;
    callers cannot split a single message across multiple buffers.

  - Allocates five slices per call (iovs, msgs, and the three result
    slices). A future RecvmmsgInto variant taking caller-allocated
    storage would eliminate this for steady-state high-rate consumers.

  - MSG_WAITFORONE is accepted but has no effect given the
    nonblocking-fd + poller pattern.
@nickgarlis nickgarlis changed the title conn_linux: add recvmmsg WIP: conn_linux: add recvmmsg May 18, 2026
@SuperQ

SuperQ commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Still WIP?

@nickgarlis

Copy link
Copy Markdown
Collaborator Author

Still WIP?

Yes, I've opened an upstream PR to support multi-arch since it's tricky to manually re-create all of those structs here.

golang/sys#276

@SuperQ
SuperQ marked this pull request as draft May 26, 2026 09:08
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.

2 participants