<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello, I think the observed performance difference is probably due to the heap array being static final. I tested on latest mainline, and ffm is consistently slower without a static final object that it can constant fold against: it exhibited similar performance
for auto arena 100 vs byte array 100, both having a significant overhead compared to Unsafe, unless the byte array is a constant (in a static final field). Meanwhile, I cannot reproduce FFM being faster than Unsafe for heap access: in the best case FFM is
still slightly slower than Unsafe.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
For context, I used the source code at <a href="https://github.com/tomerr90/UnsafeVSFMA/blob/main/src/main/java/org/example/FMASerDe.java">
https://github.com/tomerr90/UnsafeVSFMA/blob/main/src/main/java/org/example/FMASerDe.java</a> and edited around. I recommend testing against 22 or later releases where FFM has finalized; the preview feature on 21 is no longer maintained.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards, Chen Liang</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> panama-dev <panama-dev-retn@openjdk.org> on behalf of Tomer Zeltzer <tomerr90@gmail.com><br>
<b>Sent:</b> Thursday, April 17, 2025 6:31 AM<br>
<b>To:</b> panama-dev@openjdk.org <panama-dev@openjdk.org><br>
<b>Subject:</b> Potential performance regression with FFM compared to Unsafe</font>
<div> </div>
</div>
<div>
<div dir="auto">Hey all!
<div dir="auto">First time emailing such a list so apologies if somwthing is "off protocol".</div>
<div dir="auto">I wrote the following article where I benchmarked FFM and Unsafe in JDK21</div>
<div dir="auto"><a href="https://itnext.io/javas-new-fma-renaissance-or-decay-372a2aee5f32">https://itnext.io/javas-new-fma-renaissance-or-decay-372a2aee5f32</a></div>
<div dir="auto"><br>
</div>
<div dir="auto">Conclusions were that FFM was 42% faster for on heap accesses while 67% slower for off heap, which is a bit weird.</div>
<div dir="auto">Code is also linked in the article.</div>
<div dir="auto">Would love hearing your thoughts!</div>
</div>
</div>
</body>
</html>