Technology1 min read

Seeing the machine code of your Java program, with a few lines of Java

By · Published by Everything Blog

In short

The tool samples running machine instructions every 10 milliseconds of CPU time to pinpoint the hottest compiled methods and their internal sample distributions. During a demonstration on an Apple M4 Max running JDK 25, the utility analyzed the `andCardinality` function from RoaringBitmap after a warm-up phase of 10,000 calls. The profiled operation completed in 115 microseconds per call, equating to roughly eight processor cycles per 64-bit word. Developers can run instructive as a straightforward Java agent, although the current disassembler cannot yet decode ARM vector instructions.

Key points

  • Instructive profiles machine code execution distributions rather than solely measuring to…: Instructive profiles machine code execution distributions rather than solely measuring total runtime like traditional JMH benchmarks.
  • The utility integrates seamlessly into standard workflows by attaching to ordinary Java p…: The utility integrates seamlessly into standard workflows by attaching to ordinary Java programs using a basic `-javaagent` argument.
  • Developers working on ARM platforms must note that the current disassembler does not supp…: Developers working on ARM platforms must note that the current disassembler does not support decoding ARM vector instructions.

Sources checked by our analysis pipeline: 1

23 November 2026 · 9 min

When I want to know why some Java code is slow, I usually reach for JMH. JMH is great to time a function. But a timing tells you how slow the code is, not why. For that, you need to see the machine code that the JIT compiler produced, and where the processor spends its time in it.

Richard Startin has a new library that does exactly that: instructive. Every 10 ms of CPU time, it records which machine instruction is running. At the end, you get the hottest compiled methods and, for each of them, how many samples landed on each instruction. It might be cooler than JMH for this purpose. Let me show you.

Bitmaps and Roaring

A bitmap is a way to store a set of integers. You use one bit per possible integer: bit i is set if i is in the set. To intersect two sets, you compute the bitwise AND of the two bitmaps, 64 bits at a time. To count the elements, you count the set bits.…

Technology