Dynamic Compiler Optimizations in the Graal VM

Since 2001, our institute is cooperating with Oracle Labs (formerly Sun Labs) on dynamic compiler optimizations and virtual machines. We contributed compiler infrastructure and optimizations both for the Java HotSpot Client compiler and for Oracle's new Graal compiler, which are now used in Oracle's Java environment all over the world.Our work concentrates on dynamic (just-in-time) compilers that compile an intermediate program representation at run time into highly optimized machine code. In contrast to static compilers (e.g., for C/C++), a dynamic (JIT) compiler imposes new challenges but also offers new optimization opportunities. Both under HotSpot and GraalVM, a program is first executed in interpreted mode, thus guaranteeing fast startup times. During interpretation, run-time profiles about execution frequencies, branch frequencies and observed run-time types are collected. When the execution frequency of a method exceeds a certain threshold, the method is considered "hot" and is passed to the JIT compiler, which compiles it to efficient machine code. Frequently called methods are then executed in machine code while rarely executed methods are interpreted, thus saving compilation time and optimizing the overall throughput.The challenge in JIT compilation is that it happens at run time and must therefore be extremely fast. Elaborate static analysis as well as traditional optimization techniques are often too time-consuming and must therefore be replaced with new and more efficient optimization algorithms. On the other hand, the collected run-time profiles can be leveraged to apply optimizations that are not possible in static compilers. It is even possible to apply "optimistic" optimizations: Usually, optimizations can only be applied when certain preconditions are guaranteed to be true. In our case, however, we can perform optimizations also when we have seen sufficient evidence for the precondition in the profile so far. If the condition turns out to be wrong during later execution, the compiled machine code can be "deoptimized" so that it falls back to non-optimized interpretation. Since that happens only rarely, optimistic optimizations usually result in a significant overall speedup in peak performance.My talk gives an overview of our collaboration with Oracle Labs and lists some of the optimizations that we contributed to the Graal compiler such as Partial Escape Analysis, Simulation-based Code Duplication and Taint Tracking. As a further example, I will present one of our recent optimizations in more detail, namely Columnar Arrays, where large arrays of objects are automatically transformed into separate arrays of object fields, thus improving cache behavior and run time in general. I will discuss the general approach of this optimization as well as its tradeoffs and caveats.

Institutions

Publication Details

Published
2024-11-13
DOI
https://doi.org/10.1109/informatics62280.2024.10900774
Primary Topic
Logic, programming, and type systems
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Dynamic Compiler Optimizations in the Graal VM

Logic, programming, and type systems
article

Dynamic Compiler Optimizations in the Graal VM

article en

Abstract

Since 2001, our institute is cooperating with Oracle Labs (formerly Sun Labs) on dynamic compiler optimizations and virtual machines. We contributed compiler infrastructure and optimizations both for the Java HotSpot Client compiler and for Oracle's new Graal compiler, which are now used in Oracle's Java environment all over the world.Our work concentrates on dynamic (just-in-time) compilers that compile an intermediate program representation at run time into highly optimized machine code. In contrast to static compilers (e.g., for C/C++), a dynamic (JIT) compiler imposes new challenges but also offers new optimization opportunities. Both under HotSpot and GraalVM, a program is first executed in interpreted mode, thus guaranteeing fast startup times. During interpretation, run-time profiles about execution frequencies, branch frequencies and observed run-time types are collected. When the execution frequency of a method exceeds a certain threshold, the method is considered "hot" and is passed to the JIT compiler, which compiles it to efficient machine code. Frequently called methods are then executed in machine code while rarely executed methods are interpreted, thus saving compilation time and optimizing the overall throughput.The challenge in JIT compilation is that it happens at run time and must therefore be extremely fast. Elaborate static analysis as well as traditional optimization techniques are often too time-consuming and must therefore be replaced with new and more efficient optimization algorithms. On the other hand, the collected run-time profiles can be leveraged to apply optimizations that are not possible in static compilers. It is even possible to apply "optimistic" optimizations: Usually, optimizations can only be applied when certain preconditions are guaranteed to be true. In our case, however, we can perform optimizations also when we have seen sufficient evidence for the precondition in the profile so far. If the condition turns out to be wrong during later execution, the compiled machine code can be "deoptimized" so that it falls back to non-optimized interpretation. Since that happens only rarely, optimistic optimizations usually result in a significant overall speedup in peak performance.My talk gives an overview of our collaboration with Oracle Labs and lists some of the optimizations that we contributed to the Graal compiler such as Partial Escape Analysis, Simulation-based Code Duplication and Taint Tracking. As a further example, I will present one of our recent optimizations in more detail, namely Columnar Arrays, where large arrays of objects are automatically transformed into separate arrays of object fields, thus improving cache behavior and run time in general. I will discuss the general approach of this optimization as well as its tradeoffs and caveats.

Johannes Kepler University of Linz (AT)
Industry, innovation and infrastructure
Openalex Percentile: Top 70%
Logic, programming, and type systems
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.