[External] : Re: MemorySegment.ofAddress(...).reinterpret(...)

Brian S O'Neill bronee at gmail.com
Thu Jul 6 22:19:15 UTC 2023


When I use the "ALL" MemorySegment instead of allocating MemorySegments 
on the fly for copies, the performance regression drops to ~2%. When I 
revert to using unsafe native field accesses (getInt, etc) and unsafe 
memory copies, the performance is back to what it was before (+/- 0.0019%).

The unsafe field access alone gives me back a bit more performance than 
the unsafe copy, but that's because field accesses are more common. The 
test runs for about nine minutes and performs ~20 million field accesses 
per second and ~12 million copies per second. Many of the copies are 
less than 10 bytes in length, and so bounds checks would add significant 
overhead.

On 2023-07-06 11:45 AM, Brian S O'Neill wrote:
> Thanks for looking into this. I'm already doing unaligned accesses, so 
> there's not much I can do at this point on my end. I'll try to identify 
> which operations are the most expensive and report back.
> 


More information about the panama-dev mailing list