HO

hotspot-jit-forensics

Debug Java performance by inspecting HotSpot JIT compilation and assembly output.

Install

mkdir -p .claude/skills/hotspot-jit-forensics && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13784" && unzip -o skill.zip -d .claude/skills/hotspot-jit-forensics && rm skill.zip

Installs to .claude/skills/hotspot-jit-forensics

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Diagnose Java performance issues by inspecting HotSpot bytecode, tiered compilation state, inlining decisions, C2 assembly, compilation limits, and object layout. Produces reproducible artifacts (jit.xml, directives, JFR, disassembly) and links them to actionable code changes.
277 charsno explicit “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Collect JVM and OS facts for diagnosis
  • Generate C2 directives files for specific methods
  • Run Java commands with compiler logging to jit.xml
  • Confirm compilation tier of Java methods
  • Capture inlining and compilation decisions for methods
  • Inspect object layout using JOL and jcmd

How it works

The skill provides a playbook and scripts to diagnose Java performance issues by inspecting HotSpot JIT compilation state, including bytecode, inlining decisions, and C2 assembly, generating reproducible artifacts for analysis.

Inputs & outputs

You give it
Running Java process PID, target Java method, Java command
You get back
jit-facts.txt, c2-directives.json5, jit.xml, assembly snippets, JOL output

When to use hotspot-jit-forensics

  • Diagnose slow hot methods
  • Analyze JIT inlining failures
  • Inspect object layout for cache efficiency

About this skill

HotSpot C2 / JIT Forensics & Optimization

A practical playbook for diagnosing Java performance issues by looking at what HotSpot actually does.

Use this skill when you suspect:

  • Lost inlining, megamorphic dispatch, or deoptimization.
  • A hot method is slow because it never reaches C2.
  • High CPU in tiny methods (often a no-inline or missed intrinsic).
  • High allocation rate or cache-unfriendly object layout.
  • Compilation failures/bailouts (node limits, method too big, deep inlining).
  • Code cache pressure, safepoint stalls, or lock contention.

Quick start (repeatable artifacts)

  1. Collect JVM facts
.codex/skills/hotspot-jit-forensics/scripts/jit-facts.sh --out jit-facts.txt

For a running process:

.codex/skills/hotspot-jit-forensics/scripts/jit-facts.sh --pid <pid> --out jit-facts.txt
  1. Generate a C2 directives file
.codex/skills/hotspot-jit-forensics/scripts/jit-directives.sh \
  --method "com/foo/MyClass.myMethod()" \
  --out c2-directives.json5
  1. Run the target command with compiler logging
.codex/skills/hotspot-jit-forensics/scripts/jit-run-log.sh \
  --directives c2-directives.json5 \
  --logfile jit.xml \
  -- java -XX:+UnlockDiagnosticVMOptions -jar app.jar

Artifacts produced:

  • jit-facts.txt (version, flags, OS/arch, optional jcmd output)
  • c2-directives.json5 (method-scoped compiler diagnostics)
  • jit.xml (HotSpot compilation log)
  • Console output with inlining and assembly (if hsdis is available)

Core workflow

1) Profile first (do not guess)

Use JFR or async-profiler to identify the actual hot method(s).

2) Confirm compilation tier

Determine if the method is interpreted, C1, or C2.

Runtime:

jcmd <pid> Compiler.codelist | head
jcmd <pid> Compiler.queue
jcmd <pid> Compiler.codecache

Start-up (noisy):

java -XX:+PrintCompilation -jar app.jar

3) Capture inlining + compilation decisions for ONE method

Prefer Compiler Directives with a focused match.

4) If assembly doesn’t print, fix hsdis

HotSpot only prints assembly with the hsdis plugin installed.

5) Read “why not inlined?” and “why not compiled?”

Check jit.xml (or JITWatch) for inline failures and compilation bailouts.

6) Inspect object layout

Use JOL (CLI or code) and jcmd class histograms.

7) Cross-check system effects

GC, safepoints, locks, and code cache can dominate CPU.


Key flags (diagnosis only)

  • -XX:+UnlockDiagnosticVMOptions
  • -XX:+LogCompilation -XX:LogFile=jit.xml
  • -XX:+CompilerDirectivesPrint -XX:CompilerDirectivesFile=c2-directives.json5
  • -XX:+PrintCompilation
  • -Xlog:safepoint=info (JDK 9+)
  • -Xlog:gc* (JDK 9+)

Script reference

jit-facts.sh

Collect JVM + OS facts and optional jcmd diagnostics into one file.

Usage: jit-facts.sh [--pid <pid>] [--out <file>]

jit-directives.sh

Generate a compiler directives file for a target method.

Usage: jit-directives.sh --method <pattern> [--out <file>]

jit-run-log.sh

Run a java command with directive-based C2 logging.

Usage: jit-run-log.sh --directives <file> --logfile <file> -- java <args...>

Deliverables checklist

  • Repro command line (exact).
  • JVM version + flags (jit-facts.txt).
  • Profile (recording.jfr or cpu.svg/alloc.svg).
  • jit.xml (LogCompilation).
  • directives file (c2-directives.json5).
  • Assembly snippet for target method(s).
  • Object layout output (JOL internals + footprint).
  • Summary: “hypothesis → evidence → change → result”.

Reference URLs

When not to use it

  • When Java performance issues are not suspected
  • When the problem is not related to HotSpot JIT compilation or C2 optimization

Limitations

  • The skill is specific to HotSpot C2/JIT forensics.
  • It focuses on diagnosing Java performance issues.
  • The analysis requires specific JVM flags and tools like hsdis.

How it compares

This skill offers a systematic approach to HotSpot JIT forensics, providing tools and a workflow to analyze low-level JVM behavior, which is more detailed than general profiling tools.

Compared to similar skills

hotspot-jit-forensics side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
hotspot-jit-forensics (this skill)03moReviewAdvanced
java-pro344moNo flagsAdvanced
managing-api-cache229dReviewAdvanced
perf-code-paths16moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry