Skip to content

vsock: reuse IoVecBuffer(Mut) buffers for packets within a device #4842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ShadowCurse
Copy link
Contributor

@ShadowCurse ShadowCurse commented Oct 8, 2024

Changes

Make vsock reuse packets for RX and TX paths. This removes overhead of creating packets from the virt queues.
This also should prevent regressions from #4799.

Reason

Improved performance.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this
    PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet
    contribution quality standards.

  • This functionality cannot be added in rust-vmm.

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 98.49246% with 3 lines in your changes missing coverage. Please review.

Project coverage is 84.38%. Comparing base (9b136c0) to head (9720925).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/vsock/csm/connection.rs 93.54% 2 Missing ⚠️
src/vmm/src/devices/virtio/vsock/packet.rs 99.25% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4842      +/-   ##
==========================================
+ Coverage   84.35%   84.38%   +0.03%     
==========================================
  Files         249      249              
  Lines       27505    27494      -11     
==========================================
- Hits        23202    23201       -1     
+ Misses       4303     4293      -10     
Flag Coverage Δ
5.10-c5n.metal 84.62% <98.49%> (+0.03%) ⬆️
5.10-m5n.metal 84.60% <98.49%> (+0.03%) ⬆️
5.10-m6a.metal 83.89% <98.49%> (+0.03%) ⬆️
5.10-m6g.metal 80.95% <98.49%> (+0.03%) ⬆️
5.10-m6i.metal 84.59% <98.49%> (+0.02%) ⬆️
5.10-m7g.metal 80.95% <98.49%> (+0.03%) ⬆️
6.1-c5n.metal 84.61% <98.49%> (+0.02%) ⬆️
6.1-m5n.metal 84.60% <98.49%> (+0.03%) ⬆️
6.1-m6a.metal 83.89% <98.49%> (+0.02%) ⬆️
6.1-m6g.metal 80.95% <98.49%> (+0.03%) ⬆️
6.1-m6i.metal 84.60% <98.49%> (+0.03%) ⬆️
6.1-m7g.metal 80.95% <98.49%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ShadowCurse ShadowCurse force-pushed the vsock_packet_refactor branch 2 times, most recently from 2842692 to 374deae Compare October 8, 2024 13:25
Add rx_packet and tx_packet members to the Vsock
type and reuse them for RX and TX processing. This removed
overhead of creating new packets for each request.

As an additional improvement, we split VsockPacket
type into 2 types: VsockPacketRx and VsockPacketTx
which allows us to separate logic for RX and TX
processing.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse force-pushed the vsock_packet_refactor branch 2 times, most recently from 8c55639 to a71f521 Compare October 8, 2024 13:42
@ShadowCurse ShadowCurse marked this pull request as ready for review October 8, 2024 13:43
@ShadowCurse ShadowCurse self-assigned this Oct 8, 2024
@ShadowCurse ShadowCurse requested a review from bchalios October 8, 2024 13:45
Copy link
Contributor

@bchalios bchalios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a couple of nits.

Can you please run A/B for this change before merging?

@bchalios bchalios changed the title vsock: reuse packets vsock: reuse IoVecBuffer(Mut) buffers for packets within a connection Oct 8, 2024
@ShadowCurse ShadowCurse force-pushed the vsock_packet_refactor branch from a71f521 to 4ef1fd6 Compare October 8, 2024 14:37
As we don't create IoVecBuffer(Mut) types
at runtime, but reuse existing ones in both
virtio-net and virtio-vsock, we don't need to
use SmallVec type anymore.
With this we remove the type alias.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse force-pushed the vsock_packet_refactor branch from 4ef1fd6 to 9720925 Compare October 8, 2024 14:40
@ShadowCurse ShadowCurse requested review from bchalios and roypat October 8, 2024 15:06
@ShadowCurse ShadowCurse merged commit 6e9d294 into firecracker-microvm:main Oct 8, 2024
5 of 7 checks passed
@ShadowCurse ShadowCurse deleted the vsock_packet_refactor branch October 8, 2024 15:31
@roypat roypat changed the title vsock: reuse IoVecBuffer(Mut) buffers for packets within a connection vsock: reuse IoVecBuffer(Mut) buffers for packets within a device Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants