<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof"><span class="x_elementToProof FluidPluginCopy"><span class="x_elementToProof x_ContentPasted1 ContentPasted1" style="font-size:12pt;color:rgb(0, 0, 0) !important;background-color:rgb(255, 255, 255) !important">This
 is the following up message for <a href="https://mail.openjdk.org/pipermail/jdk-dev/2023-January/007288.html" target="_blank" rel="noopener noreferrer" data-auth="NotApplicable" data-safelink="true" data-linkindex="0" class="ContentPasted1">
https://mail.openjdk.org/pipermail/jdk-dev/2023-January/007288.html</a>.</span></span>
<div class="x_elementToProof FluidPluginCopy"><span class="x_elementToProof x_ContentPasted1" style="font-size:12pt;color:rgb(0, 0, 0) !important;background-color:rgb(255, 255, 255) !important"><br class="ContentPasted1">
</span></div>
<div class="x_elementToProof FluidPluginCopy"><span class="x_elementToProof x_ContentPasted1" style="font-size:12pt;color:rgb(0, 0, 0) !important;background-color:rgb(255, 255, 255) !important">
<pre class="x_FluidPluginCopy x_ContentPasted2 x_elementToProof ContentPasted1">> You do:
>  converted.intoMemorySegment(MemorySegment.ofArray(control), offset, ByteOrder.nativeOrder());
>
> Can you just do: 
>
>  converted.intoArray(control, offset);
</pre>
<br class="ContentPasted1">
</span></div>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof"><span class="x_elementToProof FluidPluginCopy"><span class="x_elementToProof x_ContentPasted1 ContentPasted1" style="font-size:12pt;color:rgb(0, 0, 0) !important;background-color:rgb(255, 255, 255) !important">I
 did so because I found that Vector<Byte> actually does not have that method. After your suggestion, I switched to use ByteVector instead by Vector<Byte>. Surprisingly, this time the hashmap delivers</span></span> a better performance. It 2~3 times faster during
 the insertion procedure. However, there was still a performance gap behind the standard hashmap during finding precedure.<br>
<br>
For the ease of discussion, I attach the relevant code here:<br>
<br>
<div style="background-color:#2b2b2b;color:#a9b7c6;font-family:'FiraCode Nerd Font Mono',monospace;font-size:9.8pt" class="FluidPluginCopy">
<pre class="ContentPasted2 elementToProof"><span style="color:#cc7832" class="ContentPasted2">private int </span><span style="color:#ffc66d" class="ContentPasted2">findWithHash</span>(<span style="color:#cc7832" class="ContentPasted2">long </span>hash<span style="color:#cc7832" class="ContentPasted2">, </span><span style="color:#507874" class="ContentPasted2">K </span>key) {<br class="ContentPasted2">    <span style="color:#cc7832" class="ContentPasted2">byte </span>h2 = Util.<span style="font-style:italic" class="ContentPasted2">h2</span>(hash)<span style="color:#cc7832" class="ContentPasted2">; </span><span style="color:#808080" class="ContentPasted2">//highest 7 bits<br class="ContentPasted2"></span><span style="color:#808080" class="ContentPasted2">    </span><span style="color:#cc7832" class="ContentPasted2">int </span>position = Util.<span style="font-style:italic" class="ContentPasted2">h1</span>(hash) & <span style="color:#9876aa" class="ContentPasted2">bucketMask</span><span style="color:#cc7832" class="ContentPasted2">; </span><span style="color:#808080" class="ContentPasted2">// h1 is just long to int<br class="ContentPasted2"></span><span style="color:#808080" class="ContentPasted2">    </span><span style="color:#cc7832" class="ContentPasted2">int </span>stride = <span style="color:#6897bb" class="ContentPasted2">0</span><span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">    while </span>(<span style="color:#cc7832" class="ContentPasted2">true</span>) {<br class="ContentPasted2">        <span style="color:#cc7832" class="ContentPasted2">var </span>mask = matchByte(position<span style="color:#cc7832" class="ContentPasted2">, </span>h2).toLong()<span style="color:#cc7832" class="ContentPasted2">; </span><span style="color:#808080" class="ContentPasted2">// match byte is to load a vector of byte and do equality comparison<br class="ContentPasted2"></span><span style="color:#808080" class="ContentPasted2">        </span><span style="color:#cc7832" class="ContentPasted2">while </span>(MaskIterator.<span style="font-style:italic" class="ContentPasted2">hasNext</span>(mask)) { <br class="ContentPasted2">            <span style="color:#cc7832" class="ContentPasted2">var </span>bit = MaskIterator.<span style="font-style:italic" class="ContentPasted2">getNext</span>(mask)<span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">            </span>mask = MaskIterator.<span style="font-style:italic" class="ContentPasted2">moveNext</span>(mask)<span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">            var </span>index = (position + bit) & <span style="color:#9876aa" class="ContentPasted2">bucketMask</span><span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">            if </span>(key.equals(<span style="color:#9876aa" class="ContentPasted2">keys</span>[index])) <span style="color:#cc7832" class="ContentPasted2">return </span>index<span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">        </span>}<br class="ContentPasted2"><br class="ContentPasted2">        <span style="color:#cc7832" class="ContentPasted2">if </span>(matchEmpty(position).anyTrue()) {<br class="ContentPasted2">            <span style="color:#cc7832" class="ContentPasted2">return </span>-<span style="color:#6897bb" class="ContentPasted2">1</span><span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">        </span>}<br class="ContentPasted2"><br class="ContentPasted2">        stride += <span style="color:#9876aa;font-style:italic" class="ContentPasted2">VECTOR_LENGTH</span><span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">        </span>position = (position + stride) & <span style="color:#9876aa" class="ContentPasted2">bucketMask</span><span style="color:#cc7832" class="ContentPasted2">;<br class="ContentPasted2"></span><span style="color:#cc7832" class="ContentPasted2">    </span>}<br class="ContentPasted2">}</pre>
</div>
>From Intellij IDEA's profiler, it seems that a large portion of time is spent on building the vectormask. I see there is an underlying bTest operation converting the results to boolean array and then give the mask. Will this be internally optimized to a single
 movemask operation by JVM?<br>
</span></div>
<div class="elementToProof">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="ContentPasted0">
<img style="width: 119.816px; height: 29px; max-width: initial;" width="119" height="29" data-outlook-trace="F:1|T:1" src="cid:4401acf2-1a73-4907-9076-ac2a0432d6d7"><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="ContentPasted0">
<span style="font-family: "Calibri Light", "Helvetica Light", sans-serif;">Schrodinger ZHU Yifan, Ph.D. Student</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="ContentPasted0">
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif;">Computer Science Department, University of Rochester</span></div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"><b>Personal Email:</b></span><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"> i@zhuyi.fan</span></div>
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"><b>Work Email:</b></span><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"> yifanzhu@rochester.edu</span></div>
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"><b>Website:</b></span><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"> https://www.cs.rochester.edu/~yzhu104/Main.html</span></div>
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"><b>Github:</b></span><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"> SchrodingerZhu</span></div>
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"><b>GPG Fingerprint:</b></span><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 10pt;"> BA02CBEB8CB5D8181E9368304D2CC545A78DBCC3</span></div>
<div class="ContentPasted0"><span style="font-family: "Calibri Light", "Helvetica Light", sans-serif;"><br>
</span></div>
<img style="width: 139px; height: 29px; max-width: initial;" width="139" height="29" data-outlook-trace="F:1|T:1" src="cid:c985ec55-2a1a-4640-9eca-cd7741cf83f1"><br>
</div>
</div>
</div>
</div>
</body>
</html>