Potential performance regression with FFM compared to Unsafe

Chen Liang chen.l.liang at oracle.com
Thu Apr 17 22:17:45 UTC 2025


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.

For context, I used the source code at https://github.com/tomerr90/UnsafeVSFMA/blob/main/src/main/java/org/example/FMASerDe.java and edited around. I recommend testing against 22 or later releases where FFM has finalized; the preview feature on 21 is no longer maintained.

Regards, Chen Liang
________________________________
From: panama-dev <panama-dev-retn at openjdk.org> on behalf of Tomer Zeltzer <tomerr90 at gmail.com>
Sent: Thursday, April 17, 2025 6:31 AM
To: panama-dev at openjdk.org <panama-dev at openjdk.org>
Subject: Potential performance regression with FFM compared to Unsafe

Hey all!
First time emailing such a list so apologies if somwthing is "off protocol".
I wrote the following article where I benchmarked FFM and Unsafe in JDK21
https://itnext.io/javas-new-fma-renaissance-or-decay-372a2aee5f32

Conclusions were that FFM was 42% faster for on heap accesses while 67% slower for off heap, which is a bit weird.
Code is also linked in the article.
Would love hearing your thoughts!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20250417/1e9f072c/attachment-0001.htm>


More information about the panama-dev mailing list