Slide 1

Slide 1 text

Brought to you by Continuous Performance Regression Testing with JfrUnit Gunnar Morling Principal Software Engineer at

Slide 2

Slide 2 text

Today’s Objective: Learn About... ■ Implementing performance regression tests with JDK Flight Recorder and JfrUnit ■ Analyzing performance regressions in JDK Mission Control ■ Emitting JFR events from 3rd party libraries

Slide 3

Slide 3 text

Gunnar Morling Principal Software Engineer at Red Hat ■ Debezium ■ Quarkus ■ JfrUnit, ModiTect, kcctl ■ Spec Lead for Bean Validation 2.0 ■ Java Champion ■ @gunnarmorling

Slide 4

Slide 4 text

Challenges of Performance Tests ■ Tests based on throughput or latency are dependent on specifics of the environment ● Require production-like set-up ● Impacted by unrelated concurrent load (e.g. on CI server)

Slide 5

Slide 5 text

JfrUnit — Assert Performance Impacting Metrics ■ Assert proxy metrics like memory allocation or IO ● Based on JDK Flight Recorder events ● Failures may indicate a performance regression ■ Plain unit tests ■ Analyse in JDK Mission Control

Slide 6

Slide 6 text

Hello, JfrUnit!

Slide 7

Slide 7 text

Tools

Slide 8

Slide 8 text

OpenJDK Flight Recorder ■ “Troubleshooting, monitoring, and profiling framework embedded into the JVM” ■ 150+ built-in event types; custom ones ■ Open-source since Java 11 (backported to 8) ■ Low overhead, meant for “always-on” ■ Accessible via recording files and streaming

Slide 9

Slide 9 text

JFR Event Types https://bestsolution-at.github.io/jfr-doc/

Slide 10

Slide 10 text

OpenJDK Mission Control ■ Control, visualize, and analyze JFR recordings ■ And more: ● JMX console ● heap dump analyzer ● etc.

Slide 11

Slide 11 text

Demo Time!

Slide 12

Slide 12 text

JfrUnit — Discussion and Limitations ■ Robust tests with very fast feedback cycle ● Independent from environment ● Proactive identification of issues ■ Metrics need solid understanding; e.g. increased allocation may or may not be a problem ■ Cannot identify all issues, e.g. locks showing up only under load ■ Won’t help with issues elsewhere, e.g. a bad query execution plan

Slide 13

Slide 13 text

Wrap-Up

Slide 14

Slide 14 text

Take Aways ■ JfrUnit: a tool in the performance testing box ● Complement - no replacement - for other tests ■ JMC Agent: produce events from code not under your control ■ Move beyond Java 1.8 🚀

Slide 15

Slide 15 text

Outlook — Keeping Track of Historic Values https://horreum.hyperfoil.io/

Slide 16

Slide 16 text

Resources ■ JfrUnit https://github.com/moditect/jfrunit ■ Introduction to JfrUnit https://www.morling.dev/blog/towards-continuous-performance-regression-t esting/ ■ Introduction to JMC Agent https://developers.redhat.com/blog/2020/10/29/collect-jdk-flight-recorder-ev ents-at-runtime-with-jmc-agent/ ■ Profiling Java inside containers with ContainerJFR https://developers.redhat.com/devnation/tech-talks/containerjfr

Slide 17

Slide 17 text

Brought to you by Gunnar Morling [email protected] @gunnarmorling