compile Not so highly optimized Not so better throughput C2 (a.k.a. server compiler) Longer time to compile Highly optimized Better throughput
int b, double scale) { double threshold_scaling; if (CompilerOracle::has_option_value(method, CompileCommand::CompileThresholdScaling, threshold_scaling)) { scale *= threshold_scaling; } switch(cur_level) { case CompLevel_none: case CompLevel_limited_profile: return (i >= Tier3InvocationThreshold * scale) || (i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale); case CompLevel_full_profile: return (i >= Tier4InvocationThreshold * scale) || (i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale); default: return true; } } jdk/src/hotspot/share/compiler/compilationPolicy.cpp at jdk-21+35 · openjdk/jdk (github.com) case CompLevel_limited_profile: return (i >= Tier3InvocationThreshold * scale) || (i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale); case CompLevel_full_profile: return (i >= Tier4InvocationThreshold * scale) || (i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale);
17 (17.0.8.1) GC : G1 Max heap : 75% allocation Application framework Micronaut 4.1.3 Option +UseStringDeduplication Other options might be specified in each case. Measurement Run 1000 times Average / Percentile (50, 90, 95, 99)
are improved since the number of classes to be loaded is decreased. Cautions A little bit efforts are required to create custom JRE (e.g., Multi-stage build to create container image). Note that jdeps sometimes does not find dependency modules like jdk.crypto.ec. Custom JRE
CDS (JEP 310 / JDK 10) Application Class Data Sharing (AppCDS) stores classes used by your applications in an archive file. (The java Command (oracle.com)) Default CDS (JEP 341 / JDK 12) Created at the JDK build time by running -Xshare:dump, using G1 GC and 128M Java heap (Oracle JDK / Class Data Sharing (oracle.com)) Dynamic CDS (JEP 350 / JDK 13) Dynamic CDS archive extends application class-data sharing (AppCDS) to allow dynamic archiving of classes when a Java application exits. (Class Data Sharing (oracle.com)) CDS Archive
Available in any platforms Can coexist Dynamic CDS and static CDS. Can use CDS archives with custom JRE. Cautions As applications are updated, we have to recreate CDS archive. CDS Archive
since JDK 13 and will be removed in the future release. [JDK-8218003] Release Note: Deprecated Java Options -Xverify:none and -noverify - Java Bug System (openjdk.org) For users who need to run without startup verification AppCDS allows us to archive their classes. The classes are verified during archiving and avoid verification at runtime.
by default when CPU on the platform is multi-core processors or using 64-bit VMs. If using only C1, There is no profiling overhead. You will get better performance than when profiling is enabled. C1 only
As no profiling occurs, startup time will be reduced. Custom JRE, CDS archive, and this can be used together. Cautions This setting is not useful for long running applications, since such applications should leverage code generated by C2, which is highly optimized. C1 only
codes at build time. JDK 9-17: experimental (deprecated and removed) JDK Support GraalVM (Native Image) Azul Zulu OpenJ9, etc. Development framework support Micronaut Spring Boot AOT compilation
Lower memory footprint and other advantages Cautions AOT compilation support Neither all application development frameworks nor all distributions support AOT. Especially GraalVM Native Image, Hardware/Platform (CPU/OS) specific Long build time As of now, generated executables are not suitable for long running. A little bit effort is required for reflection support. AOT compilation
or Containers VM or Containers VM or Containers VM or Containers VM or Containers VMs or Containers Java Application JVM JIT Compilation JIT Centralization
Each JVM instance communicates with the JIT JVM instance. VM or Containers VM or Containers VM or Containers VM or Containers VM or Containers VMs or Containers Java Application JVM JIT Compilation Dedicated JVM instance(s) for JIT compilation JIT Compilation Request compilation Return generated codes JIT Centralization
smaller resources. Especially useful for apps running on containers. Might allocate smaller CPU core and memory to each container With caching compiled code in the dedicated JIT server instance, JIT compilation might be faster. Cautions Network latency (recommends to use along with Kubernetes) Might not be suitable for super short-live applications Not all distributions are supported. JIT Centralization
since characteristics of Java JIT compiler are leveraged to increase startup time. Cautions Not all distributions are supported. Depending upon distributions, how to provide/collect profile log/data is different. [ReadyNow!] -XX:ProfileLogIn=<file> -XX:ProfileLogOut=<file> [JWarmup] -XX:CompilationWarmUpLogFile=<file> Train applications
time. Code cache along with warm up feature might allow us to run applications faster and gain optimized codes. Cautions Not all distributions are supported. Use code cache
the whole Java instance state can be stored in the image. Resources like open files or sockets are cannot, so it is required to release them when checkpoint is made. CRaC emits notifications for an application to prepare for the checkpoint and return to operating state after restore." https://github.com/CRaC/docs Use checkpoint
Startup time is quite short. Cautions Strictly same dependencies and environment between executions is required. Project is undergoing. Privilege operation is required. Some efforts to capture checkpoint (Automation is a key...) Use checkpoint
time to peak performance, and footprint of Java programs. Focus Standardize AOT for Hotspot JVM Start native, but support and optimize dynamic stuff later Resources Project Leyden - Capturing Lightning in a Bottle - YouTube 202308-Leyden-JVMLS.pdf (openjdk.org) leyden-premain-petclinic-2023-09-12.pdf (openjdk.org) Project Leyden By Brian Goetz - YouTube
added ones Dynamic CDS Archive Cached Code Archive classes and heap snapshot Static CDS Archive training data pre-compiled machine code We can use these techniques now!
Updating Java version is also another option. Several projects to improve startup time are now on-going. It is the most important to choose the most suitable technique based on characteristics and requirements of applications.