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.
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
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
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"
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'
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