new: configurable UDP receive buffer (SO_RCVBUF), default 1 MB#195
Merged
Conversation
The UDP transport left the socket receive buffer at the OS default (64 KB on Windows), so a burst of incoming messages could overflow it and the OS silently dropped packets - e.g. a fast run of event notifications where the handler is slow (#132). Set it to 1 MB by default and expose a ReceiveBufferSize property that can be changed at any time, including after Start() (applied to the live socket). Over-requesting is honored on Windows and clamped to net.core.rmem_max on Linux/Raspberry Pi - never fatal, so no per-OS handling is needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the #132 investigation. The UDP transport never set the socket receive buffer, so it used the OS default (64 KB on Windows). Under a burst of incoming messages — e.g. event notifications delivered faster than a slow
OnEventNotifyhandler drains them — the buffer overflows and the OS silently drops packets. That is the "some notifications are missed" in #132.Change
ReceiveBufferSizeproperty that can be changed at any time, including afterStart()— it is applied to the live socket(s) immediately.Why 1 MB works on PC and Raspberry Pi
Over-requesting
SO_RCVBUFis never fatal:net.core.rmem_max(~208 KB default) — no error, only the clamped amount is allocated (trivial even on a 512 MB Pi). To go higher you raisenet.core.rmem_maxvia sysctl.Verified
ReceiveBufferSizereads back1048576by default and successfully changes to 4 MB afterStart()(applied to the live socket).Note: this raises the burst threshold; the deeper guidance for #132 (return fast from
OnEventNotify, offload heavy work) still stands.