[foreign-memaccess+abi] RFR: Add benchmarks to MemorySegmentVsBits

Uwe Schindler uschindler at openjdk.org
Tue Jan 3 11:34:15 UTC 2023


On Tue, 3 Jan 2023 10:24:04 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Looks good. It seems like the memory segment implementation breaks even at size = 16? On top of my head I can't explain why the plain var handle (`byteVarHandle`) is so much faster than anything else. 1but perhaps the benchmark is flawed there?

That's good! We use it everywhere in Lucene when getting long/int/short out of byte arrays :-) But I agree, the access for memory segments should be as fast as basically it is also just a VarHandle. Maybe the guards are indeed the problem.

I think, to replace `java.nio.Bits` in the JDK I would use the plain simple VarHandle instead of wrapping they bytes with a MemorySegment or a ByteBuffer. I could provide a simple PR for the JDK that changes the NIO Bits methods by delgating to the mentioned VarHandle :-). But that's unrelated to Panama, I know :-)

-------------

PR: https://git.openjdk.org/panama-foreign/pull/762


More information about the panama-dev mailing list