<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="Title" content="">
<meta name="Keywords" content="">
<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:12.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:595.0pt 842.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Hello,</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I've been measuring the performance of the java 11 built in AES-NI instructions and, with NI switched on through JAVA_TOOL_OPTIONS = ‘-XX:+UnlockDiagnosticVMOptions -XX:+UseAES -XX:+UseAESIntrinsics’.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I run the benchmarks that are present in the open jdk itself through  ‘java -server -jar target/jmh-jdk-microbenchmarks-1.0-SNAPSHOT.jar org.openjdk.bench.javax.crypto.full.AESBench.encrypt -p algorithm=AES/CTR/NoPadding’.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">When I compare the results and calculate the throughput in GB/s, for 16k encoding blocks, I get about 40% of the throughput when compared to the openssl performance test through ‘openssl speed -evp aes-128-ctr’.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I don't seem to find a decent comparison/benchmark that describes which percentage of the maximum performance to expect with jdk 11, but 40 % seems rather low. Does anybody know of a comparison (or might have
 an idea where I go wrong,  because, as these are off the shelf perf tools I would think not a lot can be tweaked there).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">For reference, the openssl test reports this:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The 'numbers' are in 1000s of bytes per second processed.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">aes-128-ctr     583576.76k  1907072.21k  4144141.40k  5612174.68k  6252751.53k  6258371.24k <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">So, for 16k blocks, 6258371k bytes per second<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The openjdk benchmark reports this<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Benchmark               (algorithm)  (dataSize)  (keyLength)  (provider)   Mode  Cnt       Score     Error  Units<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">AESBench.encrypt  AES/CTR/NoPadding       16384          128              thrpt  100  168066.873 ± 488.873  ops/s<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Out of which I conclude that, for 16k blocks, the perf here is 168066 * 16k or about 2689056k bytes per second or about 40 % of the openssl number, taking some liberty with rounding the numbers.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Is that expected or am I drawing the wrong conclusions? Or am I missing something?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">When I print the options, the jvm reports that the AES intrinsics are being used :<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">java -XX:+PrintFlagsFinal | grep -i AES<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">     intx MaxBCEAEstimateLevel                     = 5                                        {product} {default}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">     intx MaxBCEAEstimateSize                      = 150                                      {product} {default}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">     bool UseAES                                   = true                                     {product} {default}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">System specs : Ubuntu 18.04<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">openjdk version "10.0.2" 2018-07-17<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> </span><span style="font-size:11.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Kasper</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</body>
</html>