MediumExperience level: 3-5 years · 8-15 years1 min read

How does JIT compilation work (C1/C2, tiered), and why is JVM warm-up a thing?

Reviewed by Gurusankar M.

Asked inAmazonGoogleMicrosoft
#jit#c1#c2#tiered compilation#warmup#deoptimization
Report issue

Short Answer

The JVM starts by interpreting bytecode, profiles hot methods, then JIT-compiles them to optimized native code. Tiered compilation uses C1 (fast, light optimization) then C2 (slower, aggressive) for the hottest code. 'Warm-up' is the period before hot paths are C2-compiled — early requests are slower.

On this page

Concept Made Simple

Coffee Chat Question

“How does JIT compilation work (C1/C2, tiered), and why is JVM warm-up a thing?”

Remember It Faster

Mind Map Answer

Interpret
run bytecode + collect profiles
C1
quick compile, basic optimizations
C2
hottest methods, aggressive optimization
Deopt
fall back if an assumption breaks

Think Beyond the Expected

What If?

A benchmark shows the first 10k requests are slow, then it speeds up — why?

JVM warm-up: early on, code is interpreted/C1-compiled while the JIT gathers profiles; once methods are hot, C2 produces optimized native code and throughput jumps. Always warm up before measuring — and consider this for latency SLAs after deploy/restart.

Real World

Warm-up explains post-deploy latency blips and why benchmarks must warm up (JMH does this). For fast startup/low warm-up, teams use AOT/CDS, GraalVM native image, or keep instances warm.

Interviewer's Expectation

Keywords they're listening for:

  • interpret → profile → JIT
  • C1 vs C2 tiered
  • warm-up period
  • deoptimization
  • JMH/warm-up in benchmarks

Common Mistakes

  • Benchmarking without warm-up
  • Ignoring warm-up in latency SLAs after restart
  • Assuming Java is 'always interpreted' or 'always native'

Best Practices

  • Warm up before measuring (use JMH)
  • Account for warm-up in deploy/canary latency
  • Consider CDS/native-image for fast startup needs

Follow-up Questions

  1. What is deoptimization and when does it happen?
  2. How do CDS / AOT / GraalVM reduce warm-up?
  3. Why must JMH warm up before measuring?

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: JIT (JVM)
Interview question: "How does JIT compilation work (C1/C2, tiered), and why is JVM warm-up a thing?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.
Open inChatGPTGeminiClaude

Was this answer helpful?

Affiliate links

Equipment for a comfortable, productive setup.

As an Amazon Associate I earn from qualifying purchases.