Skip to content

Conversation

@AAA3M
Copy link

@AAA3M AAA3M commented Sep 15, 2025

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 openjdk/jdk#25487

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

Related issues

Backport of openjdk/jdk#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

@olivergillespie
Copy link
Contributor

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.

@shipilev
Copy link
Member

shipilev commented Sep 16, 2025

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 shipilev changed the title Backport e5ce5c57c83972ff52758a804c942986cab74ca7 from JDK 26 8357959: (bf) ByteBuffer.allocateDirect initialization can result in large TTSP spikes Sep 16, 2025
…large TTSP spikes

Backport-of: e5ce5c57c83972ff52758a804c942986cab74ca7
@AAA3M
Copy link
Author

AAA3M commented Sep 16, 2025

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

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants