$ mvn clean install
$ (cd benchmarks/; java -jar target/benchmarks.jar)
New Dell desktop
Benchmark Mode Cnt Score Error Units
ConfigServerBenchmark.devtoolsRestart avgt 10 1.034 ± 0.201 s/op
ConfigServerBenchmark.explodedJarMain avgt 10 3.271 ± 0.234 s/op
ConfigServerBenchmark.fatJar138 avgt 10 3.267 ± 0.173 s/op
ConfigServerBenchmark.fatJar142 avgt 10 3.423 ± 0.160 s/op
PetclinicBenchmark.noverify avgt 10 5.942 ± 0.300 s/op
PetclinicBenchmark.fatJar avgt 10 6.641 ± 0.248 s/op
PetclinicBenchmark.basicThin avgt 10 6.007 ± 0.359 s/op
PetclinicBenchmark.devtoolsRestart avgt 10 1.437 ± 0.226 s/op
SpringBoot138Benchmark.explodedJarLauncher avgt 10 2.832 ± 0.099 s/op
SpringBoot138Benchmark.explodedJarMain avgt 10 2.241 ± 0.158 s/op
SpringBoot138Benchmark.fatJar avgt 10 2.761 ± 0.200 s/op
SpringBoot142Benchmark.explodedJarLauncher avgt 10 3.018 ± 0.136 s/op
SpringBoot142Benchmark.explodedJarMain avgt 10 2.277 ± 0.124 s/op
SpringBoot142Benchmark.fatJar avgt 10 2.814 ± 0.088 s/op
SpringBootThinBenchmark.basic138Thin avgt 10 2.550 ± 0.115 s/op
SpringBootThinBenchmark.basic142Thin avgt 10 2.783 ± 0.129 s/op
>5 year old Dell desktop
Benchmark Mode Cnt Score Error Units
ConfigServerBenchmark.devtoolsRestart avgt 10 2.041 ± 0.173 s/op
ConfigServerBenchmark.explodedJarMain avgt 10 6.930 ± 0.228 s/op
ConfigServerBenchmark.fatJar138 avgt 10 7.395 ± 0.203 s/op
ConfigServerBenchmark.fatJar142 avgt 10 7.439 ± 0.247 s/op
PetclinicBenchmark.devtoolsRestart avgt 10 2.868 ± 0.195 s/op
PetclinicBenchmark.fatJar avgt 10 13.579 ± 0.222 s/op
PetclinicBenchmark.noverify avgt 10 12.186 ± 0.373 s/op
SpringBoot138Benchmark.explodedJarLauncher avgt 10 5.821 ± 0.191 s/op
SpringBoot138Benchmark.explodedJarMain avgt 10 4.365 ± 0.117 s/op
SpringBoot138Benchmark.fatJar avgt 10 5.550 ± 0.132 s/op
SpringBoot142Benchmark.explodedJarLauncher avgt 10 6.238 ± 0.225 s/op
SpringBoot142Benchmark.explodedJarMain avgt 10 4.840 ± 0.137 s/op
SpringBoot142Benchmark.fatJar avgt 10 6.238 ± 0.560 s/op
SpringBootThinBenchmark.basic138Thin avgt 10 5.248 ± 0.130 s/op
SpringBootThinBenchmark.basic142Thin avgt 10 5.715 ± 0.115 s/op
One year old Lenovo X1 laptop.
Benchmark Mode Cnt Score Error Units
ConfigServerBenchmark.devtoolsRestart avgt 10 6.007 ± 0.313 s/op
ConfigServerBenchmark.explodedJarMain avgt 10 5.217 ± 0.280 s/op
ConfigServerBenchmark.fatJar138 avgt 10 5.651 ± 0.221 s/op
ConfigServerBenchmark.fatJar142 avgt 10 5.812 ± 0.163 s/op
PetclinicBenchmark.devtoolsRestart avgt 10 6.670 ± 0.260 s/op
PetclinicBenchmark.fatJar avgt 10 9.973 ± 0.637 s/op
PetclinicBenchmark.noverify avgt 10 9.312 ± 0.350 s/op
SpringBoot138Benchmark.explodedJarLauncher avgt 10 4.696 ± 0.242 s/op
SpringBoot138Benchmark.explodedJarMain avgt 10 3.599 ± 0.192 s/op
SpringBoot138Benchmark.fatJar avgt 10 4.427 ± 0.249 s/op
SpringBoot142Benchmark.explodedJarLauncher avgt 10 4.926 ± 0.313 s/op
SpringBoot142Benchmark.explodedJarMain avgt 10 3.824 ± 0.150 s/op
SpringBoot142Benchmark.fatJar avgt 10 4.814 ± 0.199 s/op
SpringBootThinBenchmark.basic138Thin avgt 10 4.370 ± 0.200 s/op
SpringBootThinBenchmark.basic142Thin avgt 10 4.796 ± 0.165 s/op
Slightly knackered old Lenovo X220 laptop.
Benchmark Mode Cnt Score Error Units
ConfigServerBenchmark.devtoolsRestart avgt 10 6.242 ± 0.232 s/op
ConfigServerBenchmark.fatJar138 avgt 10 6.267 ± 0.274 s/op
ConfigServerBenchmark.fatJar142 avgt 10 6.426 ± 0.398 s/op
ConfigServerBenchmark.explodedJarMain avgt 10 5.880 ± 0.326 s/op
PetclinicBenchmark.devtoolsRestart avgt 10 6.910 ± 0.293 s/op
PetclinicBenchmark.fatJar avgt 10 11.241 ± 0.365 s/op
PetclinicBenchmark.noverify avgt 10 10.726 ± 0.526 s/op
SpringBoot138Benchmark.explodedJarLauncher avgt 10 5.526 ± 0.341 s/op
SpringBoot138Benchmark.explodedJarMain avgt 10 4.190 ± 0.201 s/op
SpringBoot138Benchmark.fatJar avgt 10 5.325 ± 0.206 s/op
SpringBoot142Benchmark.explodedJarLauncher avgt 10 5.958 ± 0.190 s/op
SpringBoot142Benchmark.explodedJarMain avgt 10 4.589 ± 0.258 s/op
SpringBoot142Benchmark.fatJar avgt 10 5.638 ± 0.269 s/op
SpringBootThinBenchmark.basic138Thin avgt 10 5.082 ± 0.307 s/op
SpringBootThinBenchmark.basic142Thin avgt 10 5.731 ± 0.211 s/op
There’s a tool in the JDK called jcmd
that prints out a load of useful stuff
about a running process. E.g:
$ jcmd <PID> PerfCounter.print
where <PID>
is the process id. The petclinic (on "tower") has these
times in ns (highlights):
...
sun.classloader.findClassTime=2051631382
sun.classloader.parentDelegationTime=220795236
sun.cls.appClassLoadTime=2315218900
sun.cls.classInitTime=1058084598
sun.cls.classLinkedTime=1142874583
sun.cls.classVerifyTime=1037315846
sun.cls.defineAppClassTime=946831715
sun.cls.lookupSysClassTime=28253463
sun.cls.parseClassTime=1055187254
sun.cls.sharedClassLoadTime=581133
sun.cls.sysClassLoadTime=223416957
sun.urlClassLoader.readClassBytesTime=299665148
...
So you can immediately save up to a second by using -noverify
(probably not advisable in production, but the jury is out on
that). The benchmark results confirm this the saving is actually only
700ms, but that’s a start.
Other things that stick out are
-
findClassTime
- time spent working out where the damn things are, loading the bytes, parsing the bytes and defining them to build Class instances (2052ms). -
readClassBytesTime
- time from when you have a reference to where the bytes are to the time you have read them in (300ms).
Also interesting (not shown above) is java.cls.loadedClasses
, at
10660. Perhaps this is over optimistic but maybe some chunk of them is
being touched by accident that aren’t necessary and they can be
skipped, or deferred.