[foreign-jextract] RFR: MemorySegmentPool + Allocator [v9]
Radoslaw Smogura
github.com+7535718+rsmogura at openjdk.java.net
Fri Apr 23 01:16:41 UTC 2021
On Thu, 22 Apr 2021 22:42:09 GMT, Radoslaw Smogura <github.com+7535718+rsmogura at openjdk.org> wrote:
>> (Preview)
>>
>> The MemorySegmentPool is a pool maintaining memory segments, optionally can expose allocator which can be bound to other scope, and which will return allocated segments back to pool.
>>
>> However the best results has been achieved by using getSegmentEntry & putSegmentEntry methods.
>>
>> The pool is intended to be used by long running applications (i.e. like global shared pool), where fast allocation and de-allocation of segments is critical (was designed during implementation of I/O subsystem with Panama, as a pool for temporary buffers between system I/O methods and Java byte arrays from InputStreams).
>>
>> The pool uses hand-made SpinLockQueue as the Deque from JDK offers too much functionality and overhead.
>
> Radoslaw Smogura has updated the pull request incrementally with one additional commit since the last revision:
>
> Prevent double adding element to queue
>
> Dealt with slow write issue - had to create segment with aligned size, not
> a bit shift.
>
> ForceInline allocatorForScope and allocate method - this is outcome
> from performance tests, and probable scalarization of segment.
>
> Some changes to inlining / no inlining.
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.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/509
More information about the panama-dev
mailing list