一句话:系统化复用 JVM 运行时数据(JIT profile、AOT 代码与 CDS),显著加速 Java 应用启动与预热。
JVM 存在启动慢与预热慢的问题:每次运行同一应用都要重新构建类元数据、方法 profile 数据以及即时编译(JIT)生成的原生代码。已有技术如类数据共享(CDS)与提前编译(AOT)分别致力于复用类元数据与编译代码,但彼此独立开发、难以相互借力。本文提出系统性复用 JVM 运行时数据的方法:首先实现 JWarmup,记录并复用 JIT 编译数据(含已编译方法及其 profile 数据);随后将 JIT 编译数据馈入 AOT 编译器以执行 profile 引导优化(PGO);并进一步整合现有 CDS 与 AOT 技术共同优化启动。在真实应用上的评估表明,该方法可将应用启动性能提升 41.35%,同时能提前触发 JIT 编译并降低峰值时段的 CPU 负载。
Java virtual machine (JVM) has the well-known slow startup and warmup issues. This is because the JVM needs to dynamically create many runtime data before reaching peak performance, including class metadata, method profile data, and just-in-time (JIT) compiled native code, for each run of even the same application. Many techniques are then proposed to reuse and share these runtime data across different runs. For example, Class Data Sharing (CDS) and Ahead-of-time (AOT) compilation aim to save and share class metadata and compiled native code, respectively. Unfortunately, these techniques are developed independently and cannot leverage the ability of each other well. This paper presents an approach that systematically reuses JVM runtime data to accelerate application startup and warmup. We first propose and implement JWarmup, a technique that can record and reuse JIT compilation data (e.g., compiled methods and their profile data). Then, we feed JIT compilation data to the AOT compiler to perform profile-guided optimization (PGO). We also integrate existing CDS and AOT techniques to further optimize application startup. Evaluation on real-world applications shows that our approach can bring a 41.35% improvement to the application startup. Moreover, our approach can trigger JIT compilation in advance and reduce CPU load at peak time.
DOI 原文 ·
@inproceedings{paperbot6615,
title = {Towards a Serverless Java Runtime},
author = {Yifei Zhang and Tianxiao Gu and Xiaolin Zheng and Lei Yu and Wei Kuai and Sanhong Li},
booktitle = {ASE},
year = {2021},
doi = {10.1109/ase51524.2021.9678709}
}