<div dir="ltr">Zhu I'm very interested in this discussion, in the event there were mails that were dropped, FWIW<div>A SwissTable implementation based on Vector intrinsics + FFM API would be super useful for a lot of applications.<br><div><br></div><div>This is the history that I see:</div><div><br></div><div><img src="cid:ii_lcm3o1yd0" alt="image.png" width="562" height="201"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 6, 2023 at 11:32 AM Paul Sandoz <<a href="mailto:paul.sandoz@oracle.com">paul.sandoz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In some further replies I just noticed you dropped the panama-dev email. Resend a summary of the discussion?<br>
<br>
Paul.<br>
<br>
> On Jan 5, 2023, at 2:16 PM, Zhu, Yifan <<a href="mailto:yzhu104@UR.Rochester.edu" target="_blank">yzhu104@UR.Rochester.edu</a>> wrote:<br>
> <br>
> I am confused. It seems that my replies are detached from the mailling list. It that expected?<br>
> <br>
> <br>
> <Outlook-3cjuahvq.png><br>
> Schrodinger ZHU Yifan, Ph.D. Student<br>
> Computer Science Department, University of Rochester<br>
> <br>
> Personal Email: i@zhuyi.fan<br>
> Work Email: <a href="mailto:yifanzhu@rochester.edu" target="_blank">yifanzhu@rochester.edu</a><br>
> Website: <a href="https://www.cs.rochester.edu/~yzhu104/Main.html" rel="noreferrer" target="_blank">https://www.cs.rochester.edu/~yzhu104/Main.html</a><br>
> Github: SchrodingerZhu<br>
> GPG Fingerprint: BA02CBEB8CB5D8181E9368304D2CC545A78DBCC3<br>
> <br>
> <Outlook-fjqcbbcv.svg><br>
> å‘件人: panama-dev <<a href="mailto:panama-dev-retn@openjdk.org" target="_blank">panama-dev-retn@openjdk.org</a>> ä»£è¡¨ Paul Sandoz <<a href="mailto:paul.sandoz@oracle.com" target="_blank">paul.sandoz@oracle.com</a>><br>
> å‘送时间: 2023å¹´1月6æ—¥ 0:29<br>
> æ”¶ä»¶äºº: Zhu, Yifan <<a href="mailto:yzhu104@UR.Rochester.edu" target="_blank">yzhu104@UR.Rochester.edu</a>><br>
> æŠ„送: <a href="mailto:panama-dev@openjdk.org" target="_blank">panama-dev@openjdk.org</a> <<a href="mailto:panama-dev@openjdk.org" target="_blank">panama-dev@openjdk.org</a>><br>
> ä¸»é¢˜: [EXT] Re: Follow-up results for SwissTable with Vector API<br>
>  <br>
> Hi,<br>
> <br>
> I saw you sent another email prior to this, but for some reason it got lost by the moderation system. (Since you are not a member of the list the emails need to be moderated and approved.)<br>
>  <br>
> <br>
> > On Jan 5, 2023, at 8:09 AM, Zhu, Yifan <<a href="mailto:yzhu104@UR.Rochester.edu" target="_blank">yzhu104@UR.Rochester.edu</a>> wrote:<br>
> > <br>
> > This is the following up message for <a href="https://urldefense.com/v3/__https://mail.openjdk.org/pipermail/jdk-dev/2023-January/007288.html__;!!CGUSO5OYRnA7CQ!c6-WVSHfkvXgbKEtNWhxgdZ9EHDDMbmUz9AbxpvbYN54xt_4LzTwYJd4PdHmueDBCmryWsWBXfjE-Jpw_Cfrf6WyAw$" rel="noreferrer" target="_blank">https://urldefense.com/v3/__https://mail.openjdk.org/pipermail/jdk-dev/2023-January/007288.html__;!!CGUSO5OYRnA7CQ!c6-WVSHfkvXgbKEtNWhxgdZ9EHDDMbmUz9AbxpvbYN54xt_4LzTwYJd4PdHmueDBCmryWsWBXfjE-Jpw_Cfrf6WyAw$</a> .<br>
> > <br>
> > > You do:<br>
> > >  converted.intoMemorySegment(MemorySegment.ofArray(control), offset, ByteOrder.nativeOrder());<br>
> > ><br>
> > > Can you just do: <br>
> > ><br>
> > >  converted.intoArray(control, offset);<br>
> > <br>
> > <br>
> > I did so because I found that Vector<Byte> actually does not have that method.<br>
> <br>
> Ah, yes. There could be an perf issue with memory segment access, although since you had to wrap the array in a segment there will be some cost to that. It’s like if you wrapped the control array in a segment and stored in a field it would work better. <br>
> <br>
> <br>
> > After your suggestion, I switched to use ByteVector instead by Vector<Byte>. Surprisingly, this time the hashmap delivers a better performance. It 2~3 times faster during the insertion procedure. <br>
> <br>
> Good!<br>
> <br>
> <br>
> > 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>
> > private int findWithHash(long hash, K key) {<br>
> >  Â  Â byte h2 = Util.h2(hash); //highest 7 bits<br>
> >  Â  Â int position = Util.h1(hash) & bucketMask; // h1 is just long to int<br>
> >  Â  Â int stride = 0;<br>
> >  Â  Â while (true) {<br>
> >  Â  Â  Â  Â var mask = matchByte(position, h2).toLong(); // match byte is to load a vector of byte and do equality comparison<br>
> >  Â  Â  Â  Â while (MaskIterator.hasNext(mask)) { <br>
> >  Â  Â  Â  Â  Â  Â var bit = MaskIterator.getNext(mask);<br>
> >  Â  Â  Â  Â  Â  Â mask = MaskIterator.moveNext(mask);<br>
> >  Â  Â  Â  Â  Â  Â var index = (position + bit) & bucketMask;<br>
> >  Â  Â  Â  Â  Â  Â if (key.equals(keys[index])) return index;<br>
> >  Â  Â  Â  Â }<br>
> > <br>
> >  Â  Â  Â  Â if (matchEmpty(position).anyTrue()) {<br>
> >  Â  Â  Â  Â  Â  Â return -1;<br>
> >  Â  Â  Â  Â }<br>
> > <br>
> >  Â  Â  Â  Â stride += VECTOR_LENGTH;<br>
> >  Â  Â  Â  Â position = (position + stride) & bucketMask;<br>
> >  Â  Â }<br>
> > }<br>
> > 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>
> > <br>
> <br>
> Can you get an inline/compilation trace like you did for insert?<br>
> <br>
> The VectorMask.toLong method is an intrinsic method.<br>
> <br>
> Try:<br>
> <br>
>  Â var vmask = matchByte(position, h2);<br>
>  Â var mask = mask.toLong();<br>
> <br>
> Probably will not make any difference, but if the findIInsertSlot performed ok operating on the mask returned from matchEmptyOrDelete it points to an issue with VectorMask.toLong.<br>
> <br>
> Paul.<br>
>  <br>
> > <br>
> > <Outlook-ejiaczyb.png><br>
> > Schrodinger ZHU Yifan, Ph.D. Student<br>
> > Computer Science Department, University of Rochester<br>
> > <br>
> > Personal Email: i@zhuyi.fan<br>
> > Work Email: <a href="mailto:yifanzhu@rochester.edu" target="_blank">yifanzhu@rochester.edu</a><br>
> > Website: <a href="https://www.cs.rochester.edu/~yzhu104/Main.html" rel="noreferrer" target="_blank">https://www.cs.rochester.edu/~yzhu104/Main.html</a><br>
> > Github: SchrodingerZhu<br>
> > GPG Fingerprint: BA02CBEB8CB5D8181E9368304D2CC545A78DBCC3<br>
> > <br>
> > <Outlook-3nrq0klq.svg><br>
> <br>
<br>
</blockquote></div>