Oracle Java团队发布了JEP 544提案,为HotSpot虚拟机引入提前编译(AOT)代码功能1。该方案通过在训练运行中将应用代码编译为本地机器码并存储在AOT缓存中,使优化的本地码在生产运行时立即可用1。
这项功能结合了AOT编译的快速启动优势与JIT编译的动态适应能力1。在性能表现上,当AOT缓存不含AOT代码时,启动时间减少50%-70%;含AOT代码时启动时间可减少65%-80%1。在javac基准测试中,预热时间的第一次迭代获得约75%的总体改进,第四次迭代已接近稳定状态1。
该方案支持AArch64和x64处理器架构1。AOT代码与JIT代码可兼容共存,系统可自动在两者间切换1。AOT代码生成需满足两个约束条件:CPU架构和特性相同,以及使用相同的垃圾收集器1。用户可通过命令行选项进行操作,其中训练运行使用"java -XX:AOTCacheOutput=app.aot"生成缓存,生产运行使用"java -XX:AOTCache=app.aot"加载缓存1。
Oracle's Java team has introduced JEP 544, a proposal that adds ahead-of-time (AOT) code compilation capabilities to the HotSpot virtual machine.1 The enhancement allows application code to be compiled into native machine code during a training run and cached in an AOT cache, making the optimized native code immediately available during production execution.1 This approach combines the fast startup benefits of AOT compilation with the dynamic adaptability of just-in-time (JIT) compilation.1
The performance gains are substantial.1 When the AOT cache contains compiled code, startup time improves by 65% to 80%, with improvements ranging from 50% to 70% when the cache lacks AOT code.1 Warmup time also sees significant improvements, with javac benchmarks showing approximately 75% overall improvement on the first iteration, with the fourth iteration approaching stable performance.1 The solution maintains compatibility between AOT and JIT code, automatically switching between them as needed.1
The proposal supports both AArch64 and x64 processor architectures.1 AOT code generation requires two constraints: the CPU architecture and features must be identical, and the same garbage collector must be used.1 Users can generate the AOT cache during training runs using the command java -XX:AOTCacheOutput=app.aot and load it during production execution with java -XX:AOTCache=app.aot.1
评论
还没有评论,欢迎留下第一条。