Skip to content
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

fix: reduce buffer allocation size #4830

Conversation

AaronFeickert
Copy link
Collaborator

@AaronFeickert AaronFeickert commented Oct 19, 2022

Description

Reduces the size of a buffer allocation when padding messages for encryption.

Closes issue 4829.

Motivation and Context

As noted in issue 4829, the BytesMut used to hold messages during padding and encryption allocates more space than is needed, possibly due to a mistaken assumption of the behavior of reserve(...). This PR ensures that the minimum number of extra bytes needed for padding is reserved, avoiding unnecessarily large allocation.

How Has This Been Tested?

Existing tests.

@CjS77 CjS77 added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Oct 19, 2022
@AaronFeickert AaronFeickert changed the title Reduce buffer allocation size fix: reduce buffer allocation size Oct 19, 2022
@AaronFeickert AaronFeickert marked this pull request as ready for review October 19, 2022 21:22
@AaronFeickert
Copy link
Collaborator Author

Addressed in PR 4832.

@AaronFeickert AaronFeickert deleted the message-padding-allocation branch October 20, 2022 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Message padding allocates buffer space unnecessarily
2 participants