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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Apr 23 01:26:38 UTC 2021


On Fri, 23 Apr 2021 01:13:42 GMT, Radoslaw Smogura <github.com+7535718+rsmogura at openjdk.org> wrote:

> That's depressing to admit, but the slow size reading is not caused by external circumstances.
> 
> I was returning cached segment to the client using direct API.
> 
> This segment can have bigger size than requested (bucketing), and one allocated with malloc. So if upper bound of read was segment size more data could be read. So I have to admit it's a bug in test.

I see - but shouldn't the high level API resize the segment?

I think a more robust approach would be:

* drop the low level API
* implement pool entries just in terms of a MemoryAddress (what has been returned by malloc)
* when the pool is created, add a cleanup action, so that all the entries in the pool are "freed"
* when clients request a segment, and an entry exists of matching size, take the address and create a sized segment from it with the right scope
* as now, register a cleanup action on the requesting scope, so that the segments allocated are returned to the pool when closed

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

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


More information about the panama-dev mailing list