<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=DE link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Quick Question, why did you Need to switch it on and out of curiosity how do the times look like when you switch NI off?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Greetings</p><p class=MsoNormal>Bernd</p><p class=MsoNormal>-- <br>http://bernd.eckenfels.net</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>Von: </b><a href="mailto:anthony.scarpino@oracle.com">Anthony Scarpino</a><br><b>Gesendet: </b>Montag, 3. Dezember 2018 21:13<br><b>An: </b><a href="mailto:Kasper.Janssens@wdc.com">Kasper Janssens</a>; <a href="mailto:security-dev@openjdk.java.net">security-dev@openjdk.java.net</a><br><b>Betreff: </b>Re: AES ctr benchmark performance</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>That is how I read it, but when I've done the test it's closer to 55%. </p><p class=MsoNormal>But openssl speed and jmh are not comparable.  Openssl is only running </p><p class=MsoNormal>through it's algorithm, while jmh is running through the VM and java </p><p class=MsoNormal>byte code. jmh has to do more work outside of pure crypto ops than openssl.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Tony</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 12/3/18 12:09 AM, Kasper Janssens wrote:</p><p class=MsoNormal>> Hello,</p><p class=MsoNormal>> </p><p class=MsoNormal>> I've been measuring the performance of the java 11 built in AES-NI </p><p class=MsoNormal>> instructions and, with NI switched on through JAVA_TOOL_OPTIONS = </p><p class=MsoNormal>> ‘-XX:+UnlockDiagnosticVMOptions -XX:+UseAES -XX:+UseAESIntrinsics’.</p><p class=MsoNormal>> </p><p class=MsoNormal>> I run the benchmarks that are present in the open jdk itself through  </p><p class=MsoNormal>> ‘java -server -jar target/jmh-jdk-microbenchmarks-1.0-SNAPSHOT.jar </p><p class=MsoNormal>> org.openjdk.bench.javax.crypto.full.AESBench.encrypt -p </p><p class=MsoNormal>> algorithm=AES/CTR/NoPadding’.</p><p class=MsoNormal>> </p><p class=MsoNormal>> When I compare the results and calculate the throughput in GB/s, for 16k </p><p class=MsoNormal>> encoding blocks, I get about 40% of the throughput when compared to the </p><p class=MsoNormal>> openssl performance test through ‘openssl speed -evp aes-128-ctr’.</p><p class=MsoNormal>> </p><p class=MsoNormal>> I don't seem to find a decent comparison/benchmark that describes which </p><p class=MsoNormal>> percentage of the maximum performance to expect with jdk 11, but 40 % </p><p class=MsoNormal>> seems rather low. Does anybody know of a comparison (or might have an </p><p class=MsoNormal>> idea where I go wrong,  because, as these are off the shelf perf tools I </p><p class=MsoNormal>> would think not a lot can be tweaked there).</p><p class=MsoNormal>> </p><p class=MsoNormal>> For reference, the openssl test reports this:</p><p class=MsoNormal>> </p><p class=MsoNormal>> The 'numbers' are in 1000s of bytes per second processed.</p><p class=MsoNormal>> </p><p class=MsoNormal>> type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 </p><p class=MsoNormal>> bytes  16384 bytes</p><p class=MsoNormal>> </p><p class=MsoNormal>> aes-128-ctr     583576.76k  1907072.21k  4144141.40k  5612174.68k  </p><p class=MsoNormal>> 6252751.53k  6258371.24k</p><p class=MsoNormal>> </p><p class=MsoNormal>> So, for 16k blocks, 6258371k bytes per second</p><p class=MsoNormal>> </p><p class=MsoNormal>> The openjdk benchmark reports this</p><p class=MsoNormal>> </p><p class=MsoNormal>> Benchmark               (algorithm)  (dataSize)  (keyLength)  </p><p class=MsoNormal>> (provider)   Mode  Cnt       Score     Error  Units</p><p class=MsoNormal>> </p><p class=MsoNormal>> AESBench.encrypt  AES/CTR/NoPadding       16384          </p><p class=MsoNormal>> 128              thrpt  100  168066.873 ± 488.873  ops/s</p><p class=MsoNormal>> </p><p class=MsoNormal>> Out of which I conclude that, for 16k blocks, the perf here is 168066 * </p><p class=MsoNormal>> 16k or about 2689056k bytes per second or about 40 % of the openssl </p><p class=MsoNormal>> number, taking some liberty with rounding the numbers.</p><p class=MsoNormal>> </p><p class=MsoNormal>> Is that expected or am I drawing the wrong conclusions? Or am I missing </p><p class=MsoNormal>> something?</p><p class=MsoNormal>> </p><p class=MsoNormal>> When I print the options, the jvm reports that the AES intrinsics are </p><p class=MsoNormal>> being used :</p><p class=MsoNormal>> </p><p class=MsoNormal>> java -XX:+PrintFlagsFinal | grep -i AES</p><p class=MsoNormal>> </p><p class=MsoNormal>>       intx MaxBCEAEstimateLevel                     = </p><p class=MsoNormal>> 5                                        {product} {default}</p><p class=MsoNormal>> </p><p class=MsoNormal>>       intx MaxBCEAEstimateSize                      = </p><p class=MsoNormal>> 150                                      {product} {default}</p><p class=MsoNormal>> </p><p class=MsoNormal>>       bool UseAES                                   = </p><p class=MsoNormal>> true                                     {product} {default}</p><p class=MsoNormal>> </p><p class=MsoNormal>> System specs : Ubuntu 18.04</p><p class=MsoNormal>> </p><p class=MsoNormal>> openjdk version "10.0.2" 2018-07-17</p><p class=MsoNormal>> </p><p class=MsoNormal>> OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)</p><p class=MsoNormal>> </p><p class=MsoNormal>> OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed </p><p class=MsoNormal>> mode)</p><p class=MsoNormal>> </p><p class=MsoNormal>> Kasper</p><p class=MsoNormal>> </p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>