This repository uses JMH to evaluate the performance of Log4j2 synchronous logging across different JDK versions.
Use the main branch
mvn clean
mvn install
{JAVA21_HOME}/bin/java -jar target/benchmarks.jar "FileAppenderSyncBenchmark.*" -jvmArgs "-Xmx2g -Xms2g" -f 2 -t 16 -w 10 -wi 2 -r 30 -i 2 -to 300 -prof gc -rf json
Switch to the jdk1.8 branch
mvn clean
mvn install
{JAVA8_HOME}/bin/java -jar target/benchmarks.jar "FileAppenderSyncBenchmark.*" -jvmArgs "-Xmx2g -Xms2g" -f 2 -t 16 -w 10 -wi 2 -r 30 -i 2 -to 300 -prof gc -rf json
- Laptop configuration: I5-1350P CPU, 32GB DDR5 5200 RAM, and Samsung MZVL4512HBLU-00BLL 512GB SSD.
- Log4j2 version is 2.24.3.
- Perform three performance tests and calculate the average value.
- Using Logger + FileAppender (default configuration).
JDK Version | Score | gc.alloc.rate | gc.count |
---|---|---|---|
JDK 21.05 | 33.08 ops/ms | 635.45 MB/sec | 61.33 |
JDK 1.8.171 | 47.65 ops/ms | 1,651.85 MB/sec | 294 |
Please refer to the detailed configuration parameters and execution results:jmh-result