consomme/tcp: use memcpy for ring buffer payload copy#2886
consomme/tcp: use memcpy for ring buffer payload copy#2886benhillis wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Replace byte-by-byte iterator copy with copy_from_slice on the ring buffer's contiguous slices. This compiles to memcpy and avoids per-byte iterator overhead when constructing outbound TCP packets. Add View::copy_to_slice() to encapsulate the two-slice copy pattern and remove the now-unused View::iter() method.
There was a problem hiding this comment.
Pull request overview
Optimizes Consommé’s TCP transmit path by replacing per-byte payload copying with slice-based copying that compiles down to memcpy, and centralizes the ring-buffer two-slice copy logic in View.
Changes:
- Add
View::copy_to_slice()to copy ring-buffer views into a destination buffer usingcopy_from_slice. - Remove the previous byte-by-byte iterator-based payload copy in
tcp.rsand usecopy_to_slice()instead. - Remove the now-unused
View::iter()API (replaced by the new copy helper).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vm/devices/net/net_consomme/consomme/src/tcp/ring.rs | Replaces View::iter() with View::copy_to_slice() to enable efficient contiguous/two-slice copies. |
| vm/devices/net/net_consomme/consomme/src/tcp.rs | Switches TCP payload construction from byte iteration to View::copy_to_slice() for better performance. |
You can also share your feedback on Copilot code review. Take the survey.
|
I'm going to confirm the old code isn't being optimized to use memcpy already. |
I've confirmed that the previous code generated code that does not use memcpy, but this does. |
|
Holding off on merging this for now until I can reason about some odd perf behavior we are seeing with this change. |
Replace byte-by-byte iterator copy with copy_from_slice on the ring buffer's contiguous slices. This compiles to memcpy and avoids per-byte iterator overhead when constructing outbound TCP packets.
Add View::copy_to_slice() to encapsulate the two-slice copy pattern and remove the now-unused View::iter() method.