Code Review for 7129164

Prepared by:never on Sun Jan 29 16:26:20 PST 2012
Workspace:/net/smite.us.oracle.com/export/ws/critical
Compare against: ssh://hg.openjdk.java.net/hsx/hotspot-comp-gate/hotspot
Summary of changes: 214 lines changed: 134 ins; 33 del; 47 mod; 3952 unchg
Patch of changes: 7129164.patch
Author comments:
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
Reviewed-by: kvn, iveresov

The machinery for GC_locker which supports GetPrimitiveArrayCritical
maintains a count of the number of threads that currently have raw
pointers exposed. This is used to allow existing critical sections to
drain before creating new ones so that a GC can occur. Currently
these counts are updated using atomic all the time, even if a GC isn't
being requested. This creates scalability problem when a lot of
threads are hammering atomic operations on the jni_lock_count. The
count only needs to be valid when checking if a critical section is
currently active and when draining the existing sections. The fix is
to make the count be computed as part of the safepointing machinery
and to only decrement the counters when _needs_gc is true. In debug
mode the old count is maintained and validated against the lazily
computed count.

On a microbenchmark that stresses GetPrimitiveArrayCritical with many
threads and relatively short critical section it can more than double
the throughput. This also slightly speeds up the normal
GetPrimtiveArrayCritical calls. Mostly it's not easily measurable
with larger scale programs.

Tested with microbenchmark that stresses GetPrimtiveArrayCritical and
the crypto benchmarks of specjvm2008 on x86 and sparc. I also ran the
java.io regression tests from the JDK.

Bug id: 7129164 JNI Get/ReleasePrimitiveArrayCritical don't scale
Legend: Modified file
Deleted file
New file

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/memory/gcLocker.hpp

80 lines changed: 37 ins; 20 del; 23 mod; 295 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/memory/gcLocker.inline.hpp

24 lines changed: 6 ins; 7 del; 11 mod; 61 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/memory/gcLocker.cpp

81 lines changed: 67 ins; 6 del; 8 mod; 154 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/runtime/safepoint.hpp

8 lines changed: 7 ins; 0 del; 1 mod; 245 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/runtime/safepoint.cpp

19 lines changed: 16 ins; 0 del; 3 mod; 1304 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/runtime/thread.hpp

2 lines changed: 1 ins; 0 del; 1 mod; 1893 unchg

This code review page was prepared using /never/bin/webrev (vers 23.18-hg-never-dev).