[foreign-jextract] RFR: MemorySegmentPool + Allocator [v6]
Radoslaw Smogura
github.com+7535718+rsmogura at openjdk.java.net
Wed Apr 21 07:11:21 UTC 2021
On Tue, 20 Apr 2021 17:19:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Radoslaw Smogura has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Use VH insted of volatile
>>
>> Replacee
>> // while ((int) LOCK.compareAndExchange(this, 0, 1) != 1) { }
>> while (!LOCK.compareAndSet(this, 0, 1)) { }
>>
>> Performane around 34 ns / oop
>
> src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemorySegmentPool.java line 179:
>
>> 177:
>> 178: public static class MemoryPoolSegment extends SpinLockQueue.Entry<MemoryPoolSegment> implements AutoCloseable {
>> 179: private final NativeMemorySegmentImpl memorySegment;
>
> I think this should be MemoryAddress, and the scope should be "late bound" when a segment is retrieved from the queue and requested by a client. Otherwise clients get segments with a different scope than the one they are in - which in itself is ok, but I think it's counterintuitive for an allocator associated with a scope to return segments that last longer than that scope.
>
> In fact I'm not even 100% that you need a scope for the pool itself (which could mean that the acquire is not needed).
I made a performance test, and it looks like creating new segment adds around 8ns to the test results (grow from 32 to 40).
I wonder if this would be a must have for direct pool API. Direct pool does not have to be associated with new scope.
However, for allocator version I think this should be done, as it can prevent leaking shared segment.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/509
More information about the panama-dev
mailing list