corretto-21 icon indicating copy to clipboard operation
corretto-21 copied to clipboard

8357959: (bf) ByteBuffer.allocateDirect initialization can result in large TTSP spikes

Open AAA3M opened this issue 4 months ago • 3 comments

ByteBuffer.allocateDirect initialization can result in large TTSP spikes

This backport adapts the JDK 26 improvement for ByteBuffer.allocateDirect initialization to reduce TTSP spikes. Minor conflict in template resolved manually to preserve 2023 copyright.

Description

This is a backport of a change made in https://github.com/openjdk/jdk/pull/25487

This is a performance change that prevents large safe point pauses during ByteBuffer.allocateDirect.

Related issues

Backport of https://github.com/openjdk/jdk/pull/25487

Motivation and context

This change has been added to JDK26 for a few months, and back ported to JDK25. This is a large performance gain, which would be nice to have in the 21 jdk.

How has this been tested?

This has been tested via unit test, and a reproducer run shows the performance gains from ~1s to < 1ms

https://gist.github.com/rk-kmr/be4322b72a14ae04aeefc0260c01acf6

Platform information

None

Additional context

AAA3M avatar Sep 15 '25 19:09 AAA3M

This seems to be missing the key change in src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template to actually use the new code, so I think if you run the reproducer you will not see any improvement.

olivergillespie avatar Sep 16 '25 09:09 olivergillespie

Be aware that Corretto commit metadata should follow the OpenJDK one. Current commit would get committed with Backport e5ce5c57c83972ff52758a804c942986cab74ca7 from JDK 26 as synopsis, carried from the commit messages in your branch. It should really be: 8357959: (bf) ByteBuffer.allocateDirect initialization can result in large TTSP spikes.

shipilev avatar Sep 16 '25 12:09 shipilev

Just need to run the reproducer again with the merged file changes

AAA3M avatar Sep 16 '25 12:09 AAA3M