Repository navigation
perf(vmnetsock): batch stream input and join shutdown - #291
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
The stream receive loop previously sent each frame through a separate
vmnet.WritePacketcall. It now groups complete frames already in the buffer and passes them toWritePackets. Only the first frame waits for input, so an incomplete following frame does not delay packets that are ready to send.In a local QEMU/Linux guest comparison on macOS 27 with MTU 1500, median guest-to-host TCP throughput increased from 2.83 to 6.53 Gbit/s. Host-to-guest throughput stayed about the same, 7.87 to 7.88 Gbit/s. Each version ran three times with two-second transfers in each direction. The results describe this setup.
Changes
WritePacketscall returns. This avoids a separate copy into each packet buffer. Keep complete frames ahead of malformed or truncated input.Closewaits for both transfer loops, and no separate context watcher remains outside that wait. The adapter uses three goroutines instead of four.DupandCloseownership rules. The caller owns duplicated descriptors, and the adapter borrows the interface without stopping it.The regression tests cover incomplete input, valid frames before malformed input, cancellation, descriptor ownership, and shutdown under backpressure. Stream and Datagram guests completed boot, traffic, and shutdown, with descriptor and goroutine counts back at their starting values. UDP at 20,000 packets/s had no loss, duplicates, or reordering in the measured cases. Saturation traffic still dropped packets.