Quick revision
The short answer
I would frame it as a reversible runtime choice that must be justified on our own workloads and supported for years. Benchmark gains vary and can be negative for some code shapes, so we measure on our services; we weigh vendor support, licence terms and how quickly the distribution follows OpenJDK releases and security patches; and we make sure profilers, crash analysis and diagnostics work with it. Because a JIT change is mostly a runtime switch, the exit cost stays low as long as builds remain compatible with standard OpenJDK, and we compare it with improvements available in OpenJDK itself, such as Leyden's AOT cache and regular upgrades.
What to remember
In this answer, we framed the move from C2 to Graal as a multi-year platform decision. We measured on our own workloads because benchmark gains vary and can be negative, checked support, licence and how fast the distribution follows OpenJDK patches, and confirmed that diagnostics keep working. Because a JIT change is a runtime switch, we kept the exit cost low by staying compatible with standard OpenJDK, and we compared the gain with OpenJDK's own path: C2 improvements through upgrades and Leyden's AOT cache.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would frame it as a reversible runtime choice that must be justified on our own workloads and supported for years. Benchmark gains vary and can be negative for some code shapes, so we measure on our services; we weigh vendor support, licence terms and how quickly the distribution follows OpenJDK releases and security patches; and we make sure profilers, crash analysis and diagnostics work with it. Because a JIT change is mostly a runtime switch, the exit cost stays low as long as builds remain compatible with standard OpenJDK, and we compare it with improvements available in OpenJDK itself, such as Leyden's AOT cache and regular upgrades.
Why this question is asked
Swapping the compiler under a whole fleet sounds like a technical tweak, but it is really a platform decision: it changes the JDK distribution, the vendor relationship and the tools every team uses during incidents. A few published benchmarks are not enough to justify it, and the decision will outlive the people who make it. Interviewers ask this at the director or principal level to see whether we can structure an uncertain, multi-year choice. In this answer, we will set out the questions the decision has to answer, starting with evidence from our own workloads, then support and licensing, exit cost, operations, and the alternatives, and finish with a staged decision process.
1A Quick Recap of What Is Being Changed
In standard OpenJDK builds, the top-tier JIT compiler is C2. Graal is an alternative top-tier JIT written in Java, plugged into HotSpot through the JVM Compiler Interface. It is not part of current OpenJDK builds; we get it by running a GraalVM distribution, which is a JDK built on OpenJDK with Graal included. So the real decision is not only Graal instead of C2, but this JDK distribution instead of our current one for every service.
2Evidence From Our Own Workloads
Benchmarks that show Graal ahead of C2 are real, but they measure particular code shapes. Graal tends to shine on code that allocates many short-lived objects or uses deep abstraction layers, thanks to partial escape analysis and aggressive inlining; on other code, C2 may be equal or faster, and Graal's warmup behaviour differs. Our fleet has its own mix: request handling, JSON, database drivers, maybe some numeric work.
So the first step is to measure on our services. We pick a representative set, for example ten services covering our main workload types, and run them on both compilers under replayed production traffic, comparing CPU per request, p99 latency, time to steady state and memory. A realistic result often looks mixed: some services gain 5 to 15 percent, some see nothing, one or two regress. The fleet-level benefit is the weighted sum, not the best benchmark.
| Service type | CPU per request | p99 latency | Warmup |
|---|---|---|---|
| JSON-heavy API | -11% | -6% | slightly longer |
| Stream-heavy reporting | -14% | -9% | similar |
| DB-bound CRUD service | -1% | no change | similar |
| Numeric pricing engine | +4% | +3% | longer |
3Support, Licensing and Release Cadence
A fleet runtime needs years of security patches delivered quickly. So we ask: who supports this distribution, under what terms and at what cost; how soon after an OpenJDK security release does it ship the corresponding patch; does it follow the same LTS versions we plan to use; and what happens if the vendor changes direction. GraalVM's editions, licence terms and release alignment with Java have changed several times, so we read the current roadmap and contract terms rather than assumptions from a few years ago, and we consider what we would do if the edition we choose stopped being offered.
4Keeping the Exit Cost Low
The good news is that a JIT change is mostly a runtime switch. The application bytecode is the same; we change the JDK in the image. As long as our builds stay compatible with standard OpenJDK, using only standard APIs and no distribution-specific features, we can switch back by changing the base image. That makes the decision much less risky than it looks, and it is a strong reason to adopt the JIT only, rather than also adopting native image or Truffle features that would tie code to the distribution.
We protect that reversibility deliberately: CI keeps building and testing on standard OpenJDK as well, and the base image choice is one configuration value per service.
5Operations: Tools Must Keep Working
During an incident, teams rely on profilers, thread and heap dumps, JFR, crash logs and the JVM's diagnostic commands. Before a fleet-wide move, we check that each of these works with the chosen distribution: async-profiler and JFR produce usable stacks for Graal-compiled code, crash analysis works, monitoring agents are supported, and JIT diagnostics give equivalent information. A few percent of CPU is not worth a slower or blinder incident response.
- Pilot on representative servicesreplayed traffic, both compilers
- Weighted fleet saving worth it?Yescheck support and operationsNostay on C2, revisit at next LTS
- Support, licence and tools acceptable?Yesopt-in for services that gainNostay on C2
- Keep OpenJDK compatibility in CIswitching back is one image change
- Review yearly against OpenJDKC2 gains, Leyden AOT cache
5 steps in order. Play them, or step through them one at a time.
6Comparing With Alternatives in OpenJDK
Finally, we compare with what we get without changing distribution. Each OpenJDK release improves C2 and the GC, so a regular upgrade programme may deliver similar savings. If the motivation is startup and warmup rather than peak throughput, Project Leyden's AOT cache, with class loading and linking in JDK 24 and method profiles in JDK 25, addresses that within standard OpenJDK. And code-level work on the top allocation hot spots often saves more than a compiler change. A reasonable outcome is an opt-in: Graal for the services where it clearly pays, C2 for the rest, and a yearly review.
7Follow-up questions
What if the pilot shows a 10 percent fleet-wide CPU saving?
Then it is worth pursuing, as long as support, licence and tools check out. I would still roll it out by service class with canaries, keep the OpenJDK build path alive, and re-measure at each LTS, because C2 improvements may narrow the gap over time.
Why not adopt native image at the same time?
Native image is a much bigger change: closed-world builds, reflection configuration, different performance and different tools. It would raise the exit cost sharply. If some services need its fast startup, that is a separate decision with its own evaluation.
Who should own this decision?
The platform or runtime team owns the evaluation and the base images, with input from security for patch cadence, procurement for licensing, and service teams for workload coverage and tooling. The final decision and its yearly review belong to the engineering leadership that owns the platform roadmap.
8Conclusion
In this answer, we framed the move from C2 to Graal as a multi-year platform decision. We measured on our own workloads because benchmark gains vary and can be negative, checked support, licence and how fast the distribution follows OpenJDK patches, and confirmed that diagnostics keep working. Because a JIT change is a runtime switch, we kept the exit cost low by staying compatible with standard OpenJDK, and we compared the gain with OpenJDK's own path: C2 improvements through upgrades and Leyden's AOT cache.
Open with
I would frame it as a reversible runtime decision that needs evidence and long-term support. First, measure on our own workloads: published benchmarks show particular code shapes, and Graal's gains vary, sometimes negative.
Then, if they want more
I would pilot on a representative set of services with replayed traffic and compare CPU per request, p99, warmup and memory, and look at the weighted fleet effect, not the best case.
Second, support and licensing: Graal as a JIT means running a GraalVM distribution, so I would check who supports it, the licence terms, how fast it ships OpenJDK security patches and whether it follows our LTS versions; its editions and terms have changed several times, so I would read the current roadmap.
Third, exit cost: switching the JIT is mostly switching the base image, so as long as our code stays on standard APIs and CI keeps testing on OpenJDK, we can go back easily. I would avoid native image or Truffle features in the same move, because those tie us in.
Fourth, operations: profilers, JFR, crash analysis and monitoring agents must work. Finally, compare with OpenJDK's own path: C2 improves with every release, Leyden's AOT cache handles startup, and allocation fixes often save more. A likely outcome is opt-in Graal where it clearly pays, reviewed yearly.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 24, Java 25
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your organisation is considering running its JVM fleet on Graal JIT instead of C2 for...": https://scrivio-interview-library.netlify.app/java/jit-compilation/2101052ce7/