Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #795 +/- ##
==========================================
- Coverage 82.18% 82.14% -0.05%
==========================================
Files 111 111
Lines 6490 6480 -10
==========================================
- Hits 5334 5323 -11
Misses 759 759
- Partials 397 398 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Benchmarking results below. Raw Benchmark Test Output (BEFORE):Click to see resultsRaw Benchmark Test Output (AFTER):Click to see resultsAnalysis of Diff (with
|
|
There have been changes in the AEAD abstraction, so I will close this PR, and re-benchmark all the ciphers. My plan is to favor speed over code-reuse... so I might end up ditching the AEAD abstraction for concrete implementations for each cipher. E.g. After some quick testing, I found that some approaches for the nonce buffers work better for some ciphers e.g. buffer pool, stack allocated buffer, shared heap buffer, etc. |
Faster AEAD Primitives
I've found that I can make all AEAD crypto primitives even faster by having a single re-usable buffer for nonces in encrypt, and another re-usable buffer for nonces in decrypt instead of using buffer pools, e.g.:
The numbers are really significant:
However, making the change would make
Encrypt()andDecrypt()each thread-unsafe i.e. encrypt and decrypt can run at the same time but no more than one go routine can runEncrypt(), and no more than one go routine can runDecrypt()simultaneously.This is OK given usage here in
pion/dtls(packets are processed sequentially per connection)... there is never more than one Encrypt() or Decrypt() on the same cipher object at the same time...Unfortunately this package is public (
/pkg/crypto/ciphersuite) and who knows how its being used outside ofpion/dtls, it could be being used as a generic crypto primitive outside of the context of dtls e.g....So it would be unwise to go from thread-safe to thread-unsafe without a major release. I will remember to make that change right before the next major release.
Keeping this PR in draft mode until we plan on shipping a major release and decide what to do with this. Will share benchmark results soon.