JDK-8218646 : Optimize os::jvm_path()
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: os_x
  • CPU: x86
  • Submitted: 2019-02-07
  • Updated: 2022-11-08
  • Resolved: 2022-11-08
Related Reports
Relates :  
Description
os::jvm_path() calls into dladdr (on Mac), which takes time.

I've seen as much as 10ms on cold system and regularly see 2ms (2% of startup time) (on Mac)

Maybe we can cache the path somehow  (store it in a CDS archive?) or let the user pass it in, to avoid looking it up.

Observed on Mac OS X, but likely affects other systems, to different degrees (need to verify)
Comments
Runtime Triage: This is not on our current list of priorities. We will consider this feature if we receive additional customer requirements.
08-11-2022

Moving out of jdk15, not ready yet with my performance testing to verify if this is worth it.
19-03-2020

Ran an experiment locally (100 runs on a Mac) with a default VM vs hardcoded path VM: #1 For minimum time, the speedup is 2.4% #2 For average time, the speedup is 4.0% #3 For maximum time, the speedup is 3.0% Raw min/avg/max from the experiment: - before: min=64439456[ns], 0.06443945[s] avg=66669532[ns], 0.06666953[s] max=78350727[ns], 0.07835073[s] -after: min=62916036[ns], 0.06291603[s] avg=64097540[ns], 0.06409754[s] max=76102325[ns], 0.07610233[s] Attached Run.java used to run the experiment.
08-02-2019

Setting vm path is done very early in the startup routine, so can't cache it in CDS archive (it's read much later) - we could add "-Dsun.java.launcher.vm_path=" command line argument, but I'd prefer to have an automatic mechanism that does not require user intervention (do we process any files early in the startup process, where we could cache such value?)
08-02-2019

Warm profiles, looking up the path: 44.00 ms 47.3% 0 s..java (1537) 44.00 ms 47.3% 0 s...._pthread_body 0x6825 44.00 ms 47.3% 0 s......thread_start 44.00 ms 47.3% 0 s........_pthread_start 44.00 ms 47.3% 0 s.........._pthread_body 44.00 ms 47.3% 0 s............JavaMain 44.00 ms 47.3% 0 s..............InitializeJVM 44.00 ms 47.3% 0 s................JNI_CreateJavaVM 44.00 ms 47.3% 0 s..................JNI_CreateJavaVM_inner(JavaVM_**, void**, void*) 44.00 ms 47.3% 0 s....................Threads::create_vm(JavaVMInitArgs*, bool*) 14.00 ms 15.0% 0 s......................init_globals() 13.00 ms 13.9% 0 s......................call_initPhase2(Thread*) ..9.00 ms .9.6% 0 s......................Threads::initialize_java_lang_classes(JavaThread*, Thread*) ..2.00 ms .2.1% 0 s......................os::init_system_properties_values() ..2.00 ms .2.1% 0 s........................os::jvm_path(char*, int) ..2.00 ms .2.1% 0 s......................vm_init_globals() cached path: 40.00 ms 45.9% 0 s..java (1415) 40.00 ms 45.9% 0 s...._pthread_body 0x5a8b 40.00 ms 45.9% 0 s......thread_start 40.00 ms 45.9% 0 s........_pthread_start 40.00 ms 45.9% 0 s.........._pthread_body 40.00 ms 45.9% 0 s............JavaMain 40.00 ms 45.9% 0 s..............InitializeJVM 40.00 ms 45.9% 0 s................JNI_CreateJavaVM 40.00 ms 45.9% 0 s..................JNI_CreateJavaVM_inner(JavaVM_**, void**, void*) 40.00 ms 45.9% 0 s....................Threads::create_vm(JavaVMInitArgs*, bool*) 14.00 ms 16.0% 0 s......................init_globals() 13.00 ms 14.9% 0 s......................call_initPhase2(Thread*) ..8.00 ms .9.1% 0 s......................Threads::initialize_java_lang_classes(JavaThread*, Thread*) ..1.00 ms .1.1% 0 s......................vm_init_globals() In the "cached path" profile notice the absence of: ..2.00 ms .2.1% 0 s......................os::init_system_properties_values() ..2.00 ms .2.1% 0 s........................os::jvm_path(char*, int)
07-02-2019

Discovered while analyzing profiles for JDK-8208142
07-02-2019