Skip to content

App/Dynamic CDS, Shared Class Cache SCC, Ahead-of-Time AOT, OpenJDK HotSpot, Eclipse OpenJ9, Graal VM native-image

Notifications You must be signed in to change notification settings

ionutbalosin/faster-jvm-start-up-techniques

Repository files navigation

Faster JVM Start-up Techniques

Techniques about how to improve the JVM start-up time for any application running on the JVM.

Please use this tutorial in conjunction with my article Application / Dynamic Class Data Sharing In HotSpot JVM and my presentation slides Techniques for a faster JVM start-up.

Visit my web site if you are interested in further performance or software architecture-related articles.

Check my training catalog if you are interested in specialized training for your company.

Content

Projects in scope

spring-petclinic project

git clone git@github.com:spring-projects/spring-petclinic.git

Additional files are needed for the multi-stage Dockerfile but also to measure the application start-up time

cp ./additional-scripts/* ./spring-petclinic

spring-native project

git clone git@github.com:spring-projects-experimental/spring-native.git

Additional file is needed to measure the application start-up time

cp ./additional-scripts/time-to-first-response.sh ./spring-native/samples/petclinic-jpa

Disable Address Space Layout Randomization (ASLR)

For comparable results (especially in the case of App/Dynamic CDS), please make sure ASLR is disabled. For further details check JEP 310: Application Class-Data Sharing

sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"

Check the process memory

Resident Set Size (RSS) / Proportional Set Size (PSS)

When multiple JVM instances are running on the same host and the archives are shared, the overall memory is implicitly reduced. To measure it I recommend looking at the RSS and PSS of each process by using the pmap command (known to provide the most accurate information) .

Assuming there are 2 running processes and PIDs were incrementally assigned

pmap -X `pgrep -f petclinic | sed -n -e '1p'` |  sed -n -e '2p;$p'
pmap -X `pgrep -f petclinic | sed -n -e '2p'` |  sed -n -e '2p;$p'

Heap and Metaspace statistics (in HotSpot JVM)

java -Xlog:cds -Xlog:gc+heap+exit -jar -Dserver.port=8080 target/*.jar
java -Xlog:cds -Xlog:gc+heap+exit -jar -XX:SharedArchiveFile=dynamic-cds.jsa -Dserver.port=8080 target/*.jar

Once the application properly starts press CTRL+C.

Note: Check the used/committed memory

About

App/Dynamic CDS, Shared Class Cache SCC, Ahead-of-Time AOT, OpenJDK HotSpot, Eclipse OpenJ9, Graal VM native-image

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages