Potential performance regression with FFM compared to Unsafe
Tomer Zeltzer
tomerr90 at gmail.com
Fri Apr 18 21:45:46 UTC 2025
Thank you for testing this out Chen!
A number of other people were able to reproduce the on heap results so not
sure what to say here but thats the less important conclusion I think.
For off heap, having the memory segment as a final field sounds like
something that can be relevant for a very few niche use cases, if at all...
If this cant be optimized further, without the final, this means a
significant performance hit for a lot of use cases... off the top of my
head, libraries like zstd and gzip that do jni bindings
On Fri, Apr 18, 2025, 01:17 Chen Liang <chen.l.liang at oracle.com> wrote:
> 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/20250419/be086eeb/attachment.htm>
More information about the panama-dev
mailing list