On Thu, 23 Nov 2023 12:13:45 GMT, Daniel Jeliński <[email protected]> wrote:
>> Hi,
>>
>> I need a review for a new internal buffer class called AEADBufferStream.
>> AEADBufferStream extends ByteArrayOutputStream, but eliminates some data
>> checking and copying that are not necessary for what GaloisCounterMode.java
>> and ChaCha20Cipher.java need.
>>
>> The changes greatest benefit is with decryption operations.
>> ChaCha20-Poly1305 had larger performance gains by adopting similar
>> techniques that AES/GCM already uses.
>>
>> The new buffer shows up to 21% bytes/sec performance increase for decryption
>> for ChaCha20-Poly1305 and 12% for AES/GCM. 16K data sizes saw a memory
>> usage reduction of 46% with and 83% with ChaCha20-Poly1305. These results
>> come from the JMH tests updated in this request and memory usage using the
>> JMH gc profile gc.alloc.rate.norm entry
>>
>> thanks
>>
>> Tony
>
> test/micro/org/openjdk/bench/javax/crypto/full/BenchBase.java line 122:
>
>> 120: public void decrypt() throws Exception {
>> 121: decryptCipher.init(Cipher.DECRYPT_MODE, ks,
>> 122: encryptCipher.getParameters().
>
> Consider using a different method to obtain parameter spec here; the
> flamegraph suggests that `getParameters` is responsible for up to 20% of the
> time spent in these benchmarks
Thanks for point that out. I have decided to leave this as is. There are
optimizations that can be made to `getParameters` that I would like the
benchmark to measure.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16487#discussion_r1408383879