[foreign-jextract] RFR: MemorySegmentPool + Allocator
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Mon Apr 19 14:46:49 UTC 2021
On Sat, 17 Apr 2021 20:53:41 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.
And this is using low level API (this also optimizes the queue by removing CAS):
Benchmark (size) Mode Cnt Score Error Units
StrLenTest.panama_strlen_pool_low 5 avgt 30 42.199 ? 0.475 ns/op
StrLenTest.panama_strlen_pool_low 20 avgt 30 44.181 ? 0.248 ns/op
StrLenTest.panama_strlen_pool_low 100 avgt 30 60.410 ? 1.280 ns/op
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/509
More information about the panama-dev
mailing list