Repository navigation
bench: ChaCha20-Poly1305 below 1 KiB and at 4 KiB; encrypt from two pieces - #1337
Merged
Merged
Conversation
…ieces The ChaCha20-Poly1305 groups measure 16, 64, 256, 512, 768, 1024, 4096 and 16384 bytes, where TLS records fall. Out-of-place encryption takes its plaintext in two pieces, as a TLS 1.3 record's is (the payload and the content type), with aws-lc-rs's seal_out_of_place_scatter taking the last as its extra_in; and a new group measures copying the pieces into the output and encrypting it in place, which encrypt should beat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comes out of the rustls provider analysis in #991. That provider seals TLS records with ChaCha20-Poly1305, and against aws-lc-rs on a Cascade Lake–class Xeon it is 0.58–0.84× as fast below 1 KiB.
encryptfrom two pieces (a TLS 1.3 record's shape) is also 3–7% slower than copying the pieces and callingencrypt_in_place. Neither shows in the benchmarks as they are: they measure 64 B, 1 KiB and 16 KiB only, andencryptfrom a single piece. This PR changes only the benchmarks, so the PRs that follow are measured where it matters.chacha20poly1305-encrypt-out-of-placetakes its plaintext in two pieces:size - 1bytes of payload and the content type. aws-lc-rs runsseal_out_of_place_scatterwith the content type as itsextra_in; OpenSSL encrypts one buffer, as before.chacha20poly1305-copy-encrypt-in-place: this library copying the two pieces into the output, thenencrypt_in_place. It is what the provider does today, andencryptshould be no slower.On a Sapphire Rapids–class machine (AVX-512 backend),
encryptis 5–9% slower than copy +encrypt_in_placeat every size:encrypt(2 pieces)encrypt_in_place(Minimum of 41 interleaved samples each.)
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Generated by Claude Code