Skip to content

v0.4.0: load balancing, incremental reads, keepalive, slow-callback warnings, multicast - #33

Merged
y001j merged 1 commit into
masterfrom
feat/v040
Nov 22, 2026
Merged

y001j merged 1 commit into
masterfrom
feat/v040

Conversation

@y001j

@y001j y001j commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Closes the gaps found when comparing with gnet and the standard library (items verified against gnet v2.3.3 sources).

  • WithLoadBalancing: BalanceKernel (default, SO_REUSEPORT), BalanceRoundRobin, BalanceLeastConnections, BalanceSourceAddrHash (client IP). Non-kernel strategies share one listening socket; ring 0 accepts and posts each fd to the chosen ring; connections in transit count towards load so bursts spread too. Test: 40 connections over 4 rings → 10 each (RR, least-conns), all on one ring for one client IP (hash).
  • Incremental reads: Conn.Peek/Next/Discard/InboundBuffered. Bytes in the receive buffer come without a copy; unconsumed bytes are kept only for connections that use the API, so others stay zero-copy (tested).
  • WithTCPKeepAlive, WithSocketBuffers: accepted (inherited from the listener), dialed and UDP sockets; verified with getsockopt on the accepted/dialed fds. (The sockets.TCPKeepAlive field had never been applied.)
  • WithSlowCallbackWarning: slow callbacks logged + Stats.SlowCallbacks; a watchdog reports callbacks still running. Off by default.
  • UDP multicast: ListenPacket on a group address joins it (WithMulticastInterface); rings share one socket so each datagram arrives once.

Default-configuration throughput vs master: 0.98–1.04x (interleaved, 5 rounds). All tests pass under -race on both backends; new tests 5×; staticcheck clean.

CHANGELOG is set to v0.4.0 (also includes the epoll backend improvements from #32). After merging, v0.4.0 will be tagged with a GitHub release.

🤖 Generated with Claude Code

… multicast

Gaps found when comparing with gnet and the standard library:

- WithLoadBalancing: BalanceKernel (default, SO_REUSEPORT hashing),
  BalanceRoundRobin, BalanceLeastConnections and BalanceSourceAddrHash
  (by client IP). The latter three share one listening socket; ring 0
  accepts and posts each fd to the chosen ring. Connections in transit
  count towards a ring's load so bursts spread too.
- Conn.Peek / Next / Discard / InboundBuffered read the stream
  incrementally. Bytes in the receive buffer are returned without a
  copy; unconsumed bytes are kept only for connections that use the API
  (or already have kept bytes), so others stay on the zero-copy path.
  Framed's buffer is renamed to keep the two apart.
- WithTCPKeepAlive (the unused sockets.TCPKeepAlive field was never
  applied) and WithSocketBuffers, for accepted (inherited from the
  listening socket), dialed and UDP sockets.
- WithSlowCallbackWarning: callbacks taking longer than the threshold
  are logged and counted (Stats.SlowCallbacks); a watchdog goroutine
  reports a callback that is still running, which a measurement after
  the call cannot. Off by default.
- UDP multicast: ListenPacket joins a multicast group address on the
  interface from WithMulticastInterface (or the default); the rings
  share one socket so each datagram is delivered once.

Tests for each feature pass on both backends (5 runs); the default
configuration shows no throughput change against master (0.98-1.04x).
CHANGELOG: v0.4.0, including the epoll backend improvements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.79070% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.36%. Comparing base (3533385) to head (76e9041).

Files with missing lines Patch % Lines
udp.go 61.53% 15 Missing ⚠️
balance.go 82.05% 7 Missing ⚠️
conn.go 88.88% 5 Missing ⚠️
sockopt.go 71.42% 4 Missing ⚠️
server.go 85.71% 3 Missing ⚠️
codec.go 77.77% 2 Missing ⚠️
slowcb.go 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   70.44%   71.36%   +0.92%     
==========================================
  Files          25       28       +3     
  Lines        2355     2553     +198     
==========================================
+ Hits         1659     1822     +163     
- Misses        696      731      +35     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@y001j
y001j merged commit d34e73f into master Nov 22, 2026
6 checks passed
@y001j
y001j deleted the feat/v040 branch November 22, 2026 16:19
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.

1 participant