https://www.optaplanner.org/blog/2021/09/15/HowMuchFasterIsJava17.html Toggle navigation OptaPlanner logo * Home * Download * Learn + Documentation + Videos + Slides + Training + + Use cases + Compatibility + Testimonials and case studies * Get help * Source * Team * Services * Star * T * Fb * YT Fork me on GitHub * Constraint Streams get some more love * Next How much faster is Java 17? Wed 15 September 2021 Avatar Geoffrey De Smet Geoffrey De Smet --------------------------------------------------------------------- Twitter LinkedIn GitHub OptaPlanner lead Java 17 (released yesterday) comes with many new features and enhancements. However, most of those require code changes to benefit from. Except for performance. Simply switch your JDK installation and you get a free performance boost. But how much? Is it worth it? Let's find out by comparing the benchmarks of JDK 17, JDK 16 and JDK 11. Benchmark methodology * Hardware: A stable machine without any other computational demanding processes running and with Intel(r) Xeon(r) Silver 4116 @ 2.1 GHz (12 cores total / 24 threads) and 128 GiB RAM memory, running RHEL 8 x86_64. * JDKs (used to both compile and run): + JDK 11 openjdk 11.0.12 2021-07-20 OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7) OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode) + JDK 16 openjdk 16.0.2 2021-07-20 OpenJDK Runtime Environment (build 16.0.2+7-67) OpenJDK 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing) + JDK 17 (downloaded 2021-09-06) openjdk 17 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing) * JVM options: -Xmx3840M and explicitly specify a garbage collector: + -XX:+UseG1GC for G1GC, the low latency garbage collector (the default in all three JDKs). + -XX:+UseParallelGC for ParallelGC, the high throughput garbage collector. * Main class: org.optaplanner.examples.app.GeneralOptaPlannerBenchmarkApp from the module optaplanner-examples in OptaPlanner 8.10.0.Final. + Each run solves 11 planning problems with OptaPlanner, such as employee rostering, school timetabling and cloud optimization. Each planning problem runs for 5 minutes. Logging is set to INFO. The benchmark starts with a 30 second JVM warm up which is discarded. + Solving a planning problem involves no IO (except a few milliseconds during startup to load the input). A single CPU is completely saturated. It constantly creates many short-lived objects, and the GC collects them afterwards. + The benchmarks measure the number of scores calculated per second. Higher is better. Calculating a score for a proposed planning solution is non-trivial: it involves many calculations, including checking for conflicts between every entity and every other entity. * Runs: Each JDK and each garbage collector combination is run 3 times sequentially. The results below is the average of those 3 runs. Results Java 11 (LTS) and Java 16 versus Java 17 (LTS) comparison java11 java16 java17 G1GC Table 1. Score calculation count per second with G1GC on different JDKs Average Cloud Machine Course Exam Nurse Traveling balancing reassignment scheduling scheduling rostering Tournament Dataset 200c 800c B1 B10 c7 c8 s2 s3 m1 mh1 nl14 JDK 11 103,606 96,700 274,103 37,421 11,779 13,660 14,354 8,982 3,585 3,335 5,019 JDK 16 109,203 97,567 243,096 38,031 13,950 16,251 15,218 9,528 3,817 3,508 5,472 JDK 17 106,147 98,069 245,645 42,096 14,406 16,924 15,619 9,726 3,802 3,601 5,618 11 - 17 8.66% 2.45% 1.42% -10.38% 12.49% 22.30% 23.90% 8.81% 8.28% 6.05% 7.98% 11.95% 16 - 17 2.41% -2.80% 0.51% 1.05% 10.69% 3.27% 4.14% 2.63% 2.08% -0.39% 2.65% 2.67% comparison java11 java16 java17 ParallelGC Table 2. Score calculation count per second with ParallelGC on different JDKs Average Cloud balancing Machine Course Exam Nurse Traveling reassignment scheduling scheduling rostering Tournament Dataset 200c 800c B1 B10 c7 c8 s2 s3 m1 mh1 nl14 JDK 11 128,553 121,974 292,761 48,339 13,397 15,540 16,392 9,887 4,409 4,148 6,097 JDK 16 128,723 123,314 281,882 45,622 16,243 18,528 17,742 10,744 4,608 4,348 6,578 JDK 17 130,215 124,498 262,753 45,058 16,479 18,904 18,023 10,845 4,658 4,430 6,641 11 - 17 6.54% 1.29% 2.07% -10.25% -6.79% 23.00% 21.64% 9.95% 9.68% 5.63% 6.80% 8.92% 16 - 17 0.37% 1.16% 0.96% -6.79% -1.24% 1.45% 2.03% 1.59% 0.94% 1.08% 1.89% 0.96% Looking at the raw data of the 3 individual runs (not shown here), the Machine Reassignment numbers (B1 and B10) fluctuate a lot between runs on the same JDK and GC. Often by more than 10%. Note The other numbers don't suffer from this unreliability. It's arguably better to ignore the Machine Reassignment numbers. But to avoid cherry-picking data concerns, these results and averages do include them. G1GC versus ParallelGC on Java 17 comparison G1GC ParallelGC java17 Table 3. Score calculation count per second on JDK 17 with different GCs Average Cloud balancing Machine Course Exam Nurse Traveling reassignment scheduling scheduling rostering^. Tournament Dataset 200c 800c B1 B10 c7 c8 s2 s3 m1 mh1 nl14 G1GC 106,147 98,069 245,645 42,096 14,406 16,924 15,619 9,726 3,802 3,601 5,618 ParallelGC 130,215 124,498 262,753 45,058 16,479 18,904 18,023 10,845 4,658 4,430 6,641 G1 - 16.39% 22.67% 26.95% 6.96% 7.04% 14.39% 11.69% 15.39% 11.50% 22.50% 23.01% 18.20% ParallelGC Executive summary On average, for OptaPlanner use cases, these benchmarks indicate that: * Java 17 is 8.66% faster than Java 11 and 2.41% faster than Java 16 for G1GC (default). * Java 17 is 6.54% faster than Java 11 and 0.37% faster than Java 16 for ParallelGC. * The Parallel Garbage Collector is 16.39% faster than the G1 Garbage Collector. No big surprises here: the latest JDK is faster and the high throughput garbage collector is faster than the low latency garbage collector. Wait a minute here... When we benchmarked JDK 15, we saw that Java 15 was 11.24% faster than Java 11. Now, the gain of Java 17 over Java 11 is less. Does that mean that Java 17 is slower than Java 15? Well, no. Java 17 is faster than Java 15 too. Those previous benchmarks were run on a different codebase (OptaPlanner 7.44 instead of 8.10). Don't compare apples and oranges. Conclusion In conclusion, the performance gained in the JDK17 version is well worth the upgrade - at least for OptaPlanner use cases. In addition, the fastest garbage collector for these use cases is still ParallelGC, instead of G1GC (the default). --------------------------------------------------------------------- Permalink tagged as production benchmark Comments Visit our forum to comment * Constraint Streams get some more love * Next Atom News feed Don't want to miss a single blog post? Follow us on * T * Fb Blog archive Latest release * 8.11.1.Final released Tue 14 September 2021 Upcoming events * I code Java Africa Africa (virtual) - Mon 11 October 2021 + Artificial Intelligence on Quarkus: I love it when an OptaPlan comes together by Geoffrey De Smet * Joker St. Petersburg, Russia (virtual) - Sun 24 October 2021 + AI maintenance scheduling with OptaPlanner on Quarkus by Geoffrey De Smet * Devoxx Ukraine Ukraine (virtual) - Thu 18 November 2021 + Artificial Intelligence on Quarkus: I love it when an OptaPlan comes together by Geoffrey De Smet Add event / Archive Latest blog posts * How much faster is Java 17? Wed 15 September 2021 [27147a6679] Geoffrey De Smet * Constraint Streams get some more love Thu 19 August 2021 [c950743f53] Lukas Petrovicky * Let's OptaPlan your jBPM tasks (part 2) - BPM Task assigning in the cloud Mon 26 July 2021 [4a8c787544] Walter Medvedeo * Static website generation with Java, Maven and JBake Wed 9 June 2021 [27147a6679] Geoffrey De Smet * Writing fast constraints with OptaPlanner: the secret recipe Tue 25 May 2021 [c950743f53] Lukas Petrovicky * The path to OptaPlanner enlightenment starts in the logs Thu 6 May 2021 [27147a6679] Geoffrey De Smet * Batch solving a ActiveMQ queue that contains planning problem data sets in a scalable way Thu 25 March 2021 [f1b0cd1c06] Radovan Synek Blog archive Latest videos * YT A modern OO/FP constraint solver Mon 13 September 2021 [27147a6679] Geoffrey De Smet * YT Business processes task optimization in Kogito Mon 6 September 2021 [4a8c787544] Walter Medvedeo * YT School timetable optimization Sun 5 September 2021 [27147a6679] Geoffrey De Smet * YT Schedule incoming calls real-time Sun 22 August 2021 [f1b0cd1c06] Radovan Synek * YT Unit testing constraints Mon 8 March 2021 [c950743f53] Lukas Petrovicky * YT Maintenance scheduling Tue 23 February 2021 [2b5082fae5] Julian Cui * YT Vaccination appointment scheduling Tue 2 February 2021 [27147a6679] Geoffrey De Smet Video archive KIE projects * Drools rule engine * OptaPlanner constraint solver * jBPM workflow engine * Kogito Business Automation platform Community * Blog * Get Help * Team * Governance * Academic research Code * Build from source * Submit a bug * License (Apache-2.0) * Release notes * Upgrade recipes Sponsored by Red Hat More coder content at Red Hat Developers (c) Copyright 2006-2021, Red Hat, Inc. or third-party contributors - Privacy statement - Terms of use - Website info