netlink: add MessageBufferSize configuration option#270
Open
nickgarlis wants to merge 1 commit intomdlayher:mainfrom
Open
netlink: add MessageBufferSize configuration option#270nickgarlis wants to merge 1 commit intomdlayher:mainfrom
nickgarlis wants to merge 1 commit intomdlayher:mainfrom
Conversation
Add a MessageBufferSize config option to let users define the size of the copy buffer used when calling Receive. If the caller knows the maximum expected message size, they can skip the peek/allocate logic, reducing allocations and syscalls. This should improve performance in high-throughput applications. Since the kernel keeps track of the largest buffer size passed to recvmsg for a socket, MessageBufferSize needs to be set at connection initialization and cannot be changed afterwards. The truncation error has also been changed to a custom Go error instead of unix.ENOSPC, as the latter is misleading and there is little value in handling it with errors.Is. - https://github.com/torvalds/linux/blob/113ae7b4decc6c2d95bdbbe52e615a0137ef7f9f/net/netlink/af_netlink.h#L35
Collaborator
Author
|
Hmm, this seems to need a bit more work. With this change, message truncation would now be possible if the user gave the wrong input. However, with the way things are now, it's not possible to tip |
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.
Add a MessageBufferSize config option to let users define the size of the copy buffer used when calling Receive. If the caller knows the maximum expected message size, they can skip the peek/allocate logic, reducing allocations and syscalls. This should improve performance in high-throughput applications.
Since the kernel keeps track of the largest buffer size passed to recvmsg for a socket, MessageBufferSize needs to be set at connection initialization and cannot be changed afterwards.
The truncation error has also been changed to a custom Go error instead of unix.ENOSPC, as the latter is misleading and there is little value in handling it with errors.Is.