You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CipherSpi includes 3 overloads of engineDoFinal. OpenSSLCipherRSA overloads 2 of them, but not the 3rd one engineDoFinal(ByteBuffer, ByteBuffer). This method is called by Cipher when invoking doFinal.
Unfortunately, the CipherSpi implementation of engineDoFinal calls Cipher.bufferCrypt, which is slow. It makes array copies of the inputs if they are not backed by arrays. When using direct ByteBuffers, multiple unnecessary allocations and copies are made.
@flooey I spent some time hacking our ciphers to see if I could improve the performance. I created this branch. Running with GCM, I see a significant increase in performance, although we're still not as fast as the JDK. More investigation is needed, but we're getting closer.
Stepping back for a second ... Given that these ciphers do not impact TLS performance, I think we can defer this issue until after 1.0.0.
Activity
nmittler commentedon Sep 1, 2017
@carl-mastrangelo what exactly is this issue for? Adding an override or performance work?
carl-mastrangelo commentedon Sep 1, 2017
It's performance. The API call that leads to it is:
Bother
bufferandplaintextare direct buffers. If you profile that you can see the slowdown in the function I mentionedCipher.bufferCryptnmittler commentedon Sep 1, 2017
@carl-mastrangelo ah ok ... so the hope is that by adding the extra override, we will fix the perf issue. Should be an easy fix?
carl-mastrangelo commentedon Sep 1, 2017
@nmittler Yeah, but I am really not that familiar with the Conscrypt APIs. I also thought maybe it wasn't implemented on purpose.
nmittler commentedon Sep 1, 2017
@kruton @flooey any thoughts?
flooey commentedon Sep 5, 2017
Yep, this just looks like an oversight (the same problem exists in OpenSSLCipher). Should be relatively easy to fix.
nmittler commentedon Sep 12, 2017
FYI, I've been working on putting together a bechmark for our ciphers, but it's currently blocked by #330
Adding benchmark for ciphers
Adding benchmark for ciphers
Adding benchmark for ciphers
Adding benchmark for ciphers
Adding benchmark for ciphers
Adding benchmark for ciphers (#333)
nmittler commentedon Sep 18, 2017
Just added the cipher benchmark as a place to start from. A couple of things that I noticed that we can start with:
We're currently always passing arrays (or heap buffers) to JNI, which is known to be very slow. We should look into using direct
ByteBuffers instead.All the methods that take two
ByteBuffers needlessly copy twice.I suspect that resolving these two items my get us to where we need.
nmittler commentedon Sep 20, 2017
@flooey I spent some time hacking our ciphers to see if I could improve the performance. I created this branch. Running with GCM, I see a significant increase in performance, although we're still not as fast as the JDK. More investigation is needed, but we're getting closer.
Stepping back for a second ... Given that these ciphers do not impact TLS performance, I think we can defer this issue until after 1.0.0.
Adding benchmark for ciphers (#333)