Skip to content

Proposal: Tune UDP socket buffers and make chunk size configurable to improve throughput #29

Open

Description

@LinuxSuRen

Description

The README documents 15 MB/s on WiFi but only 8.35 MB/s when sending from macOS, and that limitation is still open. Two likely contributors in the current code:

  1. No socket buffer tuning anywhere — neither side calls SetReadBuffer/SetWriteBuffer. At high packet rates the kernel receive buffer overflows and drops datagrams, and the transfer degrades into the missing/resend loop. (Note: commit cb262e1 "Increase the udp buffer on darwin" actually only changed the chunk size — no buffer tuning ever landed.)
  2. Chunk size is hardcoded per OS (pkg/header.go:94: 9000 on darwin, 60000 elsewhere) with no CLI flag:
    • a 60000-byte datagram fragments into ~40 IP fragments; on lossy WiFi losing one fragment loses the whole datagram, amplifying loss,
    • the value can't be tuned per network without rebuilding.

Suggested fix

  • call SetReadBuffer/SetWriteBuffer with sensible sizes on both ends (and document the relevant sysctl limits on Linux),
  • expose --chunk on transfer send (guarded to ≤ 65357 = 65507 − 150 header bytes); the receiver already learns it from the header,
  • run a benchmark matrix {1400, 8192, 9000, 32768, 60000} × platforms before/after — related to Provide a document about how to test with a big file quickly #13 (documenting big-file testing).

Activity

  1. added
    enhancement
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions