On Fri, 19 Jun 2026 14:20:23 GMT, Jorn Vernee <[email protected]> wrote:
>> Per Minborg has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Improve performance for VTs
>
> src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java line 122:
>
>> 120:
>> 121: @ForceInline
>> 122: private NativeMemorySegmentImpl trySlice(long pool, long
>> byteSize, long byteAlignment, long poolSize) {
>
> I think you could potentially still implement Muarizio's suggestion to delay
> the creation of the segment instance. We could e.g. have an out-of-line
> allocation path that returns `long`, and then some code that wraps the result
> into a memory segment instance. Since no objects are passed over the inlining
> boundary, this should still be fast, but saves the inlining budget for other
> things in the enclosing code.
Also, could `trySlice` be `static`?
> src/java.base/share/classes/jdk/internal/foreign/ConfinedSegmentPool.java
> line 369:
>
>> 367: return target <= 1
>> 368: ? 1
>> 369: : Integer.highestOneBit(target - 1) << 1;
>
> `availableProcessors` is guaranteed to return a number "never smaller than
> 1". So this conditional isn't needed since `target` will always be at least 2.
> Suggestion:
>
> return Integer.highestOneBit(target - 1) << 1;
Also, maybe consider making the slot count configurable with a system property.
I'd imagine there are programs with many virtual threads that need to allocate.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31365#discussion_r3443074098
PR Review Comment: https://git.openjdk.org/jdk/pull/31365#discussion_r3443374610