Medium👤 3-5 years👤 8-15 years 1 min read

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

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.

Coffee Chat Question

Concept Made Simple

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

🧠Mind Map Answer

Remember It Faster

Interpretrun bytecode + collect profiles
C1quick compile, basic optimizations
C2hottest methods, aggressive optimization
Deoptfall back if an assumption breaks

🔥What If?

Think Beyond the Expected

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 → JITC1 vs C2 tieredwarm-up perioddeoptimizationJMH/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

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

🧩Related Technologies

JMHAppCDSGraalVM native imageJFR

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?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions