-
Notifications
You must be signed in to change notification settings - Fork 24
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
perf: Perf #295
perf: Perf #295
Conversation
secio/src/crypto/ring_impl.rs
Outdated
true | ||
} | ||
|
||
fn decrypt_in_place(&mut self, input: &mut bytes::BytesMut) -> Result<(), SecioError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add a new fn to trait since the invoker has the mut reference already, can we change the original fn
fn decrypt(&mut self, input: &[u8]) -> Result<Vec<u8>, SecioError>
to
fn decrypt(&mut self, input: &mut [u8]) -> Result<(), SecioError>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no new fn is added, OpenSSL will copy one more time, because OpenSSL bind does not have an in-place interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the same time, because &mut [u8]
does not have shortened semantics(In other words, it doesn't have ownership, so it cannot be deleted/shortened), the delete tag operation on in-place
cannot be performed on this type. Forcibly shortening its length with a pointer will cause a dangling pointer, so the type must be marked with shortening semantics type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about change to BytesMut?
fn decrypt(&mut self, input: &mut BytesMut) -> Result<(), SecioError>
in place decrypt on p2p bench
before:
after: