[foreign-jextract] RFR: MemorySegmentPool + Allocator [v4]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Apr 20 09:53:17 UTC 2021


On Tue, 20 Apr 2021 07:04:34 GMT, Radoslaw Smogura <github.com+7535718+rsmogura at openjdk.org> wrote:

>  Direct API has competitive performance with unsafe version

Yeah - this is the thing I find suspicious: the unsafe version "cheats" by avoiding creation of a segment the "standard" way, which required memory to be zeroed, memory limits to be updated (there are a couple of CAS to do that on allocation and then on release). So it shaves off all the "redundant" cost. But, it still does "malloc" and "free"! So, if your memory pool, can perform like the unsafe version, it seems to mean that it's not faster than malloc/free - which is odd, and I don't have an explanation as to why it is the way it is.

I think your reference/target should be more `panama_strlen_prefix`, which performs no allocation whatsoever (I would imagine that in a benchmark where I keep requesting a segment of the same size, the pool will keep recycling the existing memory and not call malloc/free, so it should be similar?).

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

PR: https://git.openjdk.java.net/panama-foreign/pull/509


More information about the panama-dev mailing list