Background
I am trying to inspect my Java batch application with Flight Recorder to improve the launching performance. Now it takes about 20 seconds to launch, and I am struggling to make it less than 10 seconds.
The application is built with Spring Boot 2.2 and Spring Batch, and running on JDK 11. I am using Flight Recorder rather than VisualVM because JDK 11 does not contain VisualVM out of the box (install of additional tools to the inspection environment is not impossible, but is restricted).
Problem
I have thought I can inspect the launching process with Flight Recoder, so I have run the application like this:
java -XX:StartFlightRecording=filename=demo.jfr,settings=profile -jar .\build\libs\demo-0.0.1-SNAPSHOT.jar -spring.batch.job.names importUserJob -spring.batch.job.enabled false
But Mission Control shows only about ~100 counts in the "Method Profiling" panel. It is too little to understand the trend of the whole launching process and inspect which method spends the most time in the process.
Question
How can I take more method count with Flight Recorder and JDK Mission Control? Which parameter in .jfc
file affects the amount of the method count?
If you are running JDK 13, or later, you can set the sampling mode to "Ludicrous".
It will sample threads once every ms. You can either go into Window -> Template Manager and select "Ludicrous" mode for Method Profiling, and export the .jfc file and start you application with it:
or you could go into JAVA_HOME/lib/jfr/ and copy the default.jfc to a new file and edit the period where it says jdk.ExecutionSample. The minimum you can set is 1 ms.
There will be increased overhead, but you will get a lot more samples.