Repository navigation
perf(vmnetsock): batch datagram forwarding - #292
Merged
Merged
Conversation
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.
Why
vmnetsock.Datagramcurrently callsWritePacketfor every datagram received from the peer. This change collects up to 32 queued datagrams and passes them toWritePacketstogether. It returns as soon as the socket has no more data, so a single packet does not wait for a full batch.Both directions use public
recvmsgandsendmsgcalls insideRawConncallbacks. Each socket syscall still handles one datagram. Batching received packets reduces calls into vmnet. Each callback also holds Go's I/O lock across several packets.In three local QEMU/HVF Linux guest runs on macOS 27.0.1 with MTU 1500, median guest-to-host TCP throughput rose from 3.19 to 5.76 Gbps. Host-to-guest throughput was 3.41 Gbps before and 3.43 Gbps after. These measurements cover one host and guest configuration.
Behavior
EAGAINwaits to avoid duplicate packets.ENOBUFS, discard the unsent remainder of the batch and continue with the next batch.DupandCloseownership rules and shutdown path. The adapter adds no goroutines and never stops its borrowed interface.Real-socket tests cover truncation, partial sends, read deadlines, and close. Native race tests cover cancellation, backpressure, and concurrent
DupandClose.Related to #205.