Video in progress
After moving to a new JDK patch or feature release, the service's throughput dropped 15%. How do you hunt for the regression at the JVM level?
First I prove that the regression comes from the JDK: the same artifact, the same load, only the JDK differs. Then I compare the two versions' flag defaults, GC numbers, JIT compilation and CPU profile side by side. The cause often turns out to be a changed default or a JIT difference in one hot method.
📖 Answer
-
Isolation. The same jar, the same image (only the JDK layer differs), the same node type, the same load generator. Run the two variants at the same time, side by side, to reduce time-dependent noise. I don't go further until I can reproduce the 15% several times.
-
The differences in defaults.
diff <(docker run old java -XX:+PrintFlagsFinal -version) \
<(docker run new java -XX:+PrintFlagsFinal -version)
Real examples: the GC default or its ergonomics changed, biased locking was disabled (15), the CPU count is calculated differently (in 19 cpu.shares stopped being counted), TLS/crypto defaults changed.
-
GC. The GC logs of both variants: allocation rate, pauses, GC CPU share. If the allocation rate changes, the JIT's escape analysis may have decided differently.
-
CPU profile. A flame graph and a differential flame graph from both variants with async-profiler. The difference usually concentrates in one or two places: an intrinsic is gone, a method is no longer inlined, new lock contention.
asprof -d 60 -e cpu -o collapsed -f old.txt <pid>
-
JIT. Compare
-XX:+PrintCompilationandLogCompilationfor the hot method, and the number of deoptimizations (JFRjdk.Deoptimization). -
Bisect. Between feature versions (17 → 21), I try the intermediate versions to find which one introduced the regression. Then I search the OpenJDK bug tracker for that component.
Once found, the options: bring back the old behavior with a flag (temporarily), adapt the code, wait for the next patch, or file a bug. On one project the cause turned out to be the TLS cipher order in the new JDK, and nobody suspected the JVM until the CPU profile showed cryptography.
Sign up to mark studied questions and save your progress.