I've seen a claim that off-heap allocation is typically 6 to 18 times faster in JDK 28. What does that improvement apply to, and does it mean native memory work in Java is faster across the board?
How much faster is off-heap allocation in JDK 28?
Answers
The claim is about allocation, not every operation on off-heap memory. The discussion connects the improvement to arenas, which manage the lifetime of memory allocated through the foreign function and memory API.
I'd treat the 6 to 18 times figure as a benchmark result, not a multiplier to apply to an entire application. The supplied discussion doesn't give enough detail about the workloads or test setup to say how typical it will be for yours.
Reply to this answer
Faster arena allocation doesn't necessarily make a custom allocator easy to build. For code that needs its own allocation strategy, calling native malloc and free through the foreign function and memory API is another option, but that comes with its own memory management responsibilities.
Reply to this answer
If you're comparing the foreign function and memory API with JNI, allocation speed alone won't tell you much. Startup can be a cost for foreign calls, including generated method handle machinery. In steady state, a suitably linked critical foreign call can get close to a JNI critical native call, subject to the restrictions and tradeoffs of those calls.
4m~bracketmixer_873:
That helps. I was mixing up the cost of getting native memory with the cost of calling native code.
Reply to this answer
It's an interesting development for workloads that use native memory, including some areas where C++ is common. But faster allocation by itself doesn't settle a language choice. There have also been specialized JVM offerings for demanding applications for some time.
Reply to this answer
Add your answer
Answers are reviewed before publication.
7e~plaidwhistle_426:
So the useful test would be the actual allocation pattern in the application, rather than just a loop allocating memory?