Skip to content

Reuse the IoVecBuffer on TX#4589

Merged
bchalios merged 1 commit intofirecracker-microvm:mainfrom
JackThomson2:iovec_reuse
Aug 8, 2024
Merged

Reuse the IoVecBuffer on TX#4589
bchalios merged 1 commit intofirecracker-microvm:mainfrom
JackThomson2:iovec_reuse

Conversation

@JackThomson2
Copy link
Contributor

Changes

Removes the allocation of the IoVecBuffer in the virtio net device during tx by reusing the same instance for each message.

To do this we have to implement Send on the type for it to work, I have tried to cover the unsafe sections the best I can.

Reason

Reduce the number of allocation

Ticket here: #4549

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
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.

Just a couple of comments regarding unnecessary SAFETY comments. Other than that LGTM

@roypat roypat added the Status: Awaiting author Indicates that an issue or pull request requires author action label Jul 1, 2024
@roypat roypat requested review from bchalios and roypat July 8, 2024 11:19
@codecov
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.99%. Comparing base (be2f41a) to head (97858a1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4589      +/-   ##
==========================================
+ Coverage   81.97%   81.99%   +0.01%     
==========================================
  Files         254      254              
  Lines       31169    31193      +24     
==========================================
+ Hits        25552    25576      +24     
  Misses       5617     5617              
Flag Coverage Δ
5.10-c5n.metal 82.00% <100.00%> (+0.02%) ⬆️
5.10-m5n.metal 81.99% <100.00%> (+0.01%) ⬆️
5.10-m6a.metal 81.29% <100.00%> (+0.02%) ⬆️
5.10-m6g.metal 79.03% <100.00%> (+0.01%) ⬆️
5.10-m6i.metal 81.98% <100.00%> (+0.01%) ⬆️
5.10-m7g.metal 79.03% <100.00%> (+0.01%) ⬆️
6.1-c5n.metal 82.00% <100.00%> (+0.01%) ⬆️
6.1-m5n.metal 81.99% <100.00%> (+0.01%) ⬆️
6.1-m6a.metal 81.29% <100.00%> (+0.01%) ⬆️
6.1-m6g.metal 79.03% <100.00%> (+0.01%) ⬆️
6.1-m6i.metal 81.99% <100.00%> (+0.02%) ⬆️
6.1-m7g.metal 79.03% <100.00%> (+0.01%) ⬆️

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.

Copy link
Contributor

@roypat roypat left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Could you just have a look at my two comments and the test failures in CI? They're related to clippy complaining about missing safety comments. For the ones in mod test, you can just add a #![allow(clippy::undocumented_unsafe_blocks)] at the top of the module. No point in annotating these in unittests.

@JackThomson2 JackThomson2 force-pushed the iovec_reuse branch 2 times, most recently from de8d373 to 90a75e2 Compare August 6, 2024 14:09
On the net virtio device reuse the IoVecBuffer on the TX path

Signed-off-by: Jack Thomson <jackabt@amazon.com>
Copy link
Contributor

@roypat roypat left a comment

Choose a reason for hiding this comment

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

🎉

@roypat roypat requested a review from bchalios August 8, 2024 09:02
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.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting author Indicates that an issue or pull request requires author action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid IoVecBuffer allocations in the TX network data path [Bug] Massive memory allocation in IO hotpath

3 participants