performance impact of JNI GetCritical*
mbien at fh-landshut.de
Thu Mar 18 11:18:39 PDT 2010
Thanks for the answer Clemens,
On 03/18/2010 06:20 PM, Clemens Eisserer wrote:
> Hi Michael,
>> How optimized are the Get/ReleasePrimitiveArrayCritical JNI functions?
>> Do they disable GC or do they only pin the array at the specific address?
> For moving gc's they actually stop the whole GC process as long as all
> arrays are released by ReleasePrimitiveArrayCritical.
> So basically the cost is some thread-synchronization (to make the gc
> know on all threads not to run now), plus the impact on the GC. So for
> small arrays theres quite high overhead.
> CMS itself is non-moving (old gen) so basically there could be some
> optimizations, but no idea wether this is actually done.
>> lets say I have a short java array of length 12. Should I copy it to a
>> direct NIO buffer and use the buffer as vehicle, use Get/ReleaseCritical
>> or something else?
> For very short arrays this is quite likely beneficial (at least if
> you're on JDK7, at least older JDK6 releases do get/releasecritical +
> memcpy in jni code).
> Just to be curious, whats your actual usecase?
the usecase was to optimize the generated code of JOGL 2 / JOAL / JOCL
etc. for some corner cases.
I feared that putting load on GetCritical* could cause GC-dependent
problems. Thats why I am already using ThreadLocal direct NIO buffers in
the high-level API of JOCL to prevent this situation.
> - Clemens
> hotspot-gc-use mailing list
> hotspot-gc-use at openjdk.java.net
More information about the hotspot-gc-use