RFR: 8175318: Performance issue regarding local JNI references

Volker Simonis volker.simonis at gmail.com
Wed Jul 19 15:34:15 UTC 2017

Looks good!

You could use:

+        for ( current = current->_next; current != NULL; current =
current->_next) {

instead of:

+        for ( ; current != NULL; current = current->_next) {

in the debug code as you already now that the first 'top' is NULL.
But that's nit picking. I'll leave it up to you if you want to do that.
There's also no need for a new webrev in case you do that change.

Thank you and best regards,

On Wed, Jul 19, 2017 at 1:39 AM, Kim Barrett <kim.barrett at oracle.com> wrote:
> Please review this fix of a performance bug in the handling of local
> JNI references.
> When allocating the first local handle for a call, we walk any
> following blocks to clear them.  All blocks after a non-full block are
> empty, as an invariant, but clearing them may be deferred.
> The problem is that on the next call we again walk and clear the
> entire list, even if most of it was never touched by the preceeding
> call.  If some call allocates a lot of local references, the
> performance of subsequent calls can be affected.
> The performance impact can be quite bad in debug builds, where the
> blocks are not only marked empty, but also have their contents zapped
> (scribbled over).  But even in release builds the difference is easily
> measurable.  See the JNIPerformance test attached to the CR.
> The solution is to only perform the clearing walk up to the next
> already cleared block (e.g. _top is 0).  Any subsequent blocks have
> already been cleared and don't need to be revisited.
> Although the same code is used for global and weak global JNI
> references, those aren't affected by the problem because we don't ever
> clear blocks in the global lists. For the global lists, only the last
> block in the list ever has a non-full _top value. This means there are
> no trailing blocks to be repeatedly walked.
> CR:
> https://bugs.openjdk.java.net/browse/JDK-8175318
> Webrev:
> http://cr.openjdk.java.net/~kbarrett/8175318/hotspot.00/
> Testing:
> rbt hs-tier[1,3], jdk-tier[1,3]
> various tonga test lists that include some jni coverage:
> nsk.jvmti, nsk.coverage, vm.runtime, vm.g1classunloading

More information about the hotspot-runtime-dev mailing list