Seeing the machine code of your Java program, with a few lines of Java
Daniel Lemire has written about instructive, a new library from Richard Startin that shows the machine code the Java JIT compiler produced for a running program. For every 10 ms of CPU time, it records which machine instruction is executing. At the end it reports the hottest compiled methods and how many samples landed on instructions. It’s added to an ordinary Java program with the -javaagent flag and about three lines of code.
Lemire used it on RoaringBitmap, the compressed bitmap library used by Apache Spark, Apache Lucene and others. He profiled the function that counts how many elements two sets have in common. On an Apple M4 Max with JDK 25, a call took 115 µs, and about 80% of the samples landed on two register copies used to count bits. JDK 27 vectorizes the loop and brings the same call down to 15.6 µs. On an Intel Xeon with AVX-512, both JDK versions reach 10 µs.
The profile is a plain Java object that can be sorted and filtered, and instructive includes rules that flag long dependency chains and loops that weren’t unrolled.
See more at lemire.me and content on GitHub .




Comments
No comments yet. Be the first to share your thoughts.