Persisting JMH Results for Regression Detection



JMH is a tool to measure Java code that is executed within  micro-second time scales. You may ask the question why do I care about the performance of code that by definition is executed in a very short period of time? It is important to only optimise code that will have a significant effect on the overall application. Sometimes a small portion of the your application's code is executed many times or your latency requirements of your application is in the micro-second time scale.

Once your application is performing as required it can be difficult to maintain that performance whilst making code changes. An automated collection of micro-benchmarks running on key components of your application is an invaluable tool in maintaining the required performance. As a starting point a history of your JMH results needs to be stored in order to analyse trends in benchmark results.

Influx JMH reporter is an open source tool we have written that parses the JMH JSON results file from a benchmark and publishes it to an InfluxDB host. We are then able to graph and analyse this data over time in order to detect regressions.

At the end of each JMH run execute:

java -jar influx-jmh-reporter-all.jar -u "http://influxhost:8086" -r results.json

This will persist the results in InfluxDB :
> show measurements
com.mycompany.mybenchmarks.PerformanceTestSuite.myBenchmark
> select * from "com.mycompany.mybenchmarks.PerformanceTestSuite.myBenchmark"
githash hostname       jvm     jvmArgs mode    score   scoreError  scoreUnit
------- --------      ---     ------- ----    -----   ----------  ---------
 7hf3k   myserver /bin/java  thrpt 28.4726       2       ops/us 
...


Stored data is monitored to detect a degradation in performance. Automated detection can be challenging as it requires isolating environmental factors in order to improve test measurement consistency.  JMH goes a long way however additional techniques such as reducing scheduling jitter (see Reducing System Jitter by Mark Price) goes much further.







Comments

Popular posts from this blog

Obtaining the time in Java with nano-second precision

Time, Where does it come from?