[foreign] Mesuring downcall stub performance

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Feb 7 14:27:20 UTC 2022


On 07/02/2022 13:55, Maurizio Cimadamore wrote:
> unsafe
> ns/q: 335.05 

Actually, this is incorrect - my run configuration was wrong. I was 
running the benchmark from intellij, which did not apply the settings as 
per your sh files.

Updated numbers:

unsafe
ns/q: 286.67

native:
ns/q: 340.21

segment:
ns/q: 340.98

I noted that the native script disables tiered compilation. Also, in 
general, in seems like things are faster with regular VM parameters. I 
have a feeling that we might need to turn this into a JMH benchmark.

On a very superficial look, while Unsafe clearly will remove bound 
checks from the code, I'm not sure about the native benchmark; that 
benchmark class still does quite a bit of access using memory segment.

Just for fun, I put together a MemoryAddress variant of the benchmark 
class, which should perform much closer to unsafe. Here's the number I got:

254.87 ns/q

Which seems even faster than unsafe (but it's probably just a blip).

In other words, it seems to me that the memory segment benchmark pays 
for bound checks, the native one pays for bound checks _and_ native 
calls. The memory address version pays for none of that (but then you 
don't get any safety).

Maurizio




More information about the panama-dev mailing list