agentleFS
CloudflareKnown publishercloudflare/quiche/datagram-socket/AGENTS.md

quiche / datagram-socket

AGENTS.md13k starsChanged 2 months agoBSD-2-ClauseView on GitHub

UDP socket abstraction layer shared across the quiche workspace. Two main concerns: DgramBuffer (a headroom-aware zero-copy byte buffer for datagrams) and DatagramSocket* traits (uniform async send/recv over UdpSocket/UnixDatagram with Linux recvmmsg/sendmmsg batching). Wraps a Vec<u8> with a pos cursor dividing it into [headroom: 0..pos][payload: pos..]. as_slice() / len() expose only the payload. BufMut writes append to the tail, independent of pos. Fast path: allocate with with_capacity_and_headroom, fill payload via BufMut, call try_add_prefix to slide pos left and write the prefix…

Trending

Less talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 2 mentionsAug 2026: 0 mentionsSep 2026: 1 mentionOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/quiche repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about cloudflare/quiche

The biggest 5 of 54 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 54

Talked about on Bluesky, GitHub and Hacker News (54 times).

On Bluesky · 27

22 more on Bluesky

On GitHub · 23

18 more on GitHub

The file

We split this AGENTS.md into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Slow path: if no headroom was pre-allocated, splice_headroom(n) does an O(payload_len) memmove to insert n bytes at the front.

    line 36
  2. Very specific:

    splice_headroom is O(n): Prefer pre-allocated headroom via with_capacity_and_headroom on hot paths.

    line 42
  3. Very specific:

    No feature flags — platform-gating via #[cfg(target_os = "linux")] and #[cfg(unix)].

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

datagram-socket/

UDP socket abstraction layer shared across the quiche workspace. Two main concerns: DgramBuffer (a headroom-aware zero-copy byte buffer for datagrams) and DatagramSocket* traits (uniform async send/recv over UdpSocket/UnixDatagram with Linux recvmmsg/sendmmsg batching).

STRUCTURE

src/
  lib.rs          Re-exports, is_nonblocking() helper
  buffer.rs       DgramBuffer — headroom-aware buffer for zero-copy datagram handling
  datagram.rs     DatagramSocket/Send/Recv traits, MaybeConnectedSocket, MAX_DATAGRAM_SIZE
  mmsg.rs         recvmmsg/sendmmsg + poll_recvmmsg!/poll_sendmmsg! macros (Linux only)
  shutdown.rs     ShutdownConnection trait
  socket_stats.rs SocketStats, QuicAuditStats, AsSocketStats

WHERE TO LOOK

TaskFileNotes
Prepend a flow ID to an outbound datagrambuffer.rstry_add_prefix (fast, zero-copy) or splice_headroom + retry (slow, O(n))
Strip a prefix from an inbound datagrambuffer.rsadvance(n) — zero copy
Implement a new socket typedatagram.rsImplement DatagramSocketSend + DatagramSocketRecv; DatagramSocket is automatic
Batch recv/send on Linuxmmsg.rsUse poll_recvmmsg! / poll_sendmmsg! macros; sendmmsg_with_suffix appends shared framing to every message
Track connection-level metricssocket_stats.rsQuicAuditStats (atomic/lock-protected); SocketStats (plain Copy struct)

DgramBuffer DESIGN

Wraps a Vec<u8> with a pos cursor dividing it into [headroom: 0..pos][payload: pos..]. as_slice() / len() expose only the payload. BufMut writes append to the tail, independent of pos.

Fast path: allocate with with_capacity_and_headroom, fill payload via BufMut, call try_add_prefix to slide pos left and write the prefix into headroom — no allocation, no memmove.

Slow path: if no headroom was pre-allocated, splice_headroom(n) does an O(payload_len) memmove to insert n bytes at the front; then retry try_add_prefix.

Stripping a prefix: advance(n) increments pos — zero-copy.

ANTI-PATTERNS

  • splice_headroom is O(n). Prefer pre-allocated headroom via with_capacity_and_headroom on hot paths.
  • MaybeConnectedSocket snapshots connectedness at construction. If the underlying socket's connected state changes after wrapping, the routing behavior will be stale.
  • recvmmsg/sendmmsg assume a connected socket (no msg_name). Do not use on unconnected sockets.

NOTES

  • No feature flags — platform-gating via #[cfg(target_os = "linux")] and #[cfg(unix)].
  • tokio-quiche sets type DgramBuf = DgramBuffer in its BufFactory impl, so all QUIC DATAGRAMs flowing through quiche::Connection in tokio-quiche are DgramBuffer instances.
  • In quiche itself, BufFactory::DgramBuf defaults to Vec<u8> — DgramBuffer is only used when tokio-quiche's BufFactory is active.
  • DGRAM_HEADROOM = 16 in tokio-quiche/src/buf_factory.rs — sized to hold two QUIC varints (max 8 bytes each).
  • MAX_DATAGRAM_SIZE = 1500 bytes.
  • The send implementation fully populates its libc::iovec storage before taking any mmsghdr.msg_iov pointers. Do not interleave pushes and pointer creation: a SmallVec reallocation would leave pointers for earlier messages dangling across the syscall.
  • unsafe impl BufMut for DgramBuffer delegates entirely to Vec<u8>'s trusted implementation; pos and BufMut's write pointer operate on non-overlapping regions.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.