Very poor performance of JNI AttachCurrentThread on Linux
Stephan Bergmann
sbergman at redhat.com
Wed Feb 27 02:01:37 PST 2013
On 02/27/2013 12:28 AM, Dean Long wrote:
> This function should only get called in debug builds or for the initial
> thread, so I'm guessing
> the app has a custom launcher because, if I'm not mistaken, the default
> launcher creates
> a separate main thread to attach to the JVM while the initial thread waits.
The app in question is LibreOffice, which has an extension mechanism
(UNO) that allows for extensions in various programming languages, among
them Java. For that, it instantiates a JVM in-process and makes JNI
calls. Due to the fundamental design of LibreOffice and its extension
mechanism, it is not practically possible in the general case to either
prevent such JNI calls from being made on the main thread, nor to
establish large scopes in which a thread will make JNI calls, to
restrict Attach/DetachCurrentThread calls to the boundaries of such
larger scopes. Therefore, LibreOffice can unfortunately end up making
rather frequent calls to Attach/DetachCurrentThread from the main thread.
Stephan
More information about the hotspot-dev
mailing list