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

perf(s2n-codec): optimize zerocopy macros #1708

Merged
merged 1 commit into from
Apr 14, 2023
Merged

Conversation

camshaft
Copy link
Contributor

@camshaft camshaft commented Apr 13, 2023

Description of changes:

While benchmarking the XDP code, I noticed the zerocopy functions showing up in the profile. It turns out that the from_bytes and as_bytes methods don't have #[inline] which misses out on some optimizations.

I've updated the codec to just use the Zerocopy traits as markers instead and then just interpreted the byte slice as a struct pointer (which is all those methods do).

Call-outs:

The XDP BPF programs had to be updated, which is actually a good sign that this is an improvement. The codesize of the programs all went down byte 40 bytes!

Testing:

All of the existing codec tests should cover this change. The functionality is equivalent.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft marked this pull request as ready for review April 14, 2023 03:10
@camshaft camshaft merged commit 171e69f into main Apr 14, 2023
@camshaft camshaft deleted the camshaft/zero-copy-opt branch April 14, 2023 17:31
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.

2 participants