On Thu, 18 Jun 2026 15:51:19 GMT, ExE Boss <[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/ConfinedSegmentPool.java > line 374: > >> 372: private static long allocatePool() { >> 373: return mallocAndZero(POOLED_MEMORY_SIZE * SLOTS); >> 374: } > > This should probably use a `POOL_OFFSET` in place of `POOLED_MEMORY_SIZE`, > which would be computed as: > > private static long poolOffset() { > final int cacheLineSize = U.dataCacheLineFlushSize(); > return cacheLineSize > 0 > ? Math.max(cacheLineSize, POOLED_MEMORY_SIZE) > : POOLED_MEMORY_SIZE; // No cache line support > } > > > So that adjacent virtual threads don’t needlessly touch each other’s cache > lines.
This is an optimization that may or may not pay off depending on the workload. On the one hand, atomic operations on pooled memory made by threads would be faster. On the other hand, we would spend more memory and observe less locality and cache utilization. Looking at the `OWNERS` memory, we will always use CAS ops on those segments, so it pays off with cache line separation. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31365#discussion_r3450689305
