Lean, Mean... Openjdk?

Lean, Mean... Openjdk?

The Lean, Mean... OpenJDK? Claes Redestad Java SE Performance Oracle Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | The Lean, Mean... OpenJDK? Who am I? ● Performance engineer at Oracle since 2012 ● OpenJDK: redestad ● Blog: https://cl4es.github.io ● Twitter: @cl4es Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | What is OpenJDK? ● The OpenJDK project started in 2006 as an open sourcing effort of the Sun JDK ● OpenJDK has been the basis of all Sun/Oracle proprietary JDK distributions since then ● Starting with JDK 11, OpenJDK and the proprietary Oracle JDK have fully converged: proprietary and/or commercial features that were only in the Oracle JDK are now freely available and part of the OpenJDK Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Did you say free? Yes! Oracle provides OpenJDK builds for free here: https://jdk.java.net/ The latest release will continue to be free and unrestricted https://blogs.oracle.com/java-platform-group/ Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | What is performance? ● Throughput Startup – The total amount of work a system can do in 1 some given time ● Latency 0.5 – The time it takes to do some unit of work Footprint 0 Latency ● Footprint – Memory and storage requirements ● Startup – The time and resources needed to get ready Throughput for action Imaginary Ideal Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Trade-offs and the ergonomic JDK Startup ● Out-of-the-box we ergonomically seek to strike a 1 good balance between all performance concerns 0.5 ● Historically the JDK has favored peak throughput Footprint 0 Latency – Some industry shift towards favoring low latency, especially as workloads scale up – To some extent tuning allow users to choose different trade-offs Throughput OpenJDK Imaginary Ideal ... goal to make (most) tuning unnecessary Source: Data and qualified guesses Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Where to start? Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | The modular JDK JDK 9 modularized the JDK Modules enable better control for developers to encapsulate internals Consolidate embedded JDKs projects into the mainline Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | The modular JDK allows us to scale down... jlink can be used to build custom JRE images from a subset of JDK modules, down to the bare minimum 350 300 250 ) b 200 M ( e 150 z i S 100 50 0 jdk my_jre base_jre $ bin/jlink --add-modules java.se,jdk.jfr --module-path jmods --output my_jre $ bin/jlink --compress=2 --add-modules java.base --module-path jmods --output base_jre Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Hello World(s)! 90 ● Out of the box, the module system 80 caused some bootstrap regressions in 70 JDK 9 60 ) 50 s m ( ● e 40 Especially running on a JRE with all JDK m i t modules 30 20 Hello World: 10 0 System.out.println("Hello World!"); 8 9 Hello World Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Hello World(s)! 90 ● We fixed many of those regressions... 80 70 ● ... and kept on fixing 60 ) 50 – 120+ startup-related enhancements s m ( e 40 m resolved in JDK 10 through JDK 13 i t 30 20 Hello World: 10 0 System.out.println("Hello World!"); 8 9 10 11 12 13 Hello World Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Hello World(s)! 60 ● Bonus: slightly better when leaving out unneeded modules 50 40 ) s m 30 ( e m i t 20 Hello World: 10 System.out.println("Hello World!"); 0 8 11 14 Hello World - JDK Hello World - java.base only Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Bootstraps, all the way up! ● In JDK 8, bootstrapping the first lambda expression took longer time than starting 140 up the entire JVM(!) 120 100 ● Early prototypes of the module system ) 80 s m ( saw use of lambdas during bootstrap e 60 m i t ● It seemed prudent to deal with this to 40 avoid even larger regressions 20 0 Hello Lambda: 8 Hello World Hello Lambda Consumer<String> println = System.out::println; println.accept("Hello World!"); Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Bootstraps, all the way up! ● For JDK 9, we spent some time cleaning things up 140 120 – Just removing a few unnecessary things and making various things initialize more lazily got us quite far 100 ● With the new jlink tool in the works we have a 80 new means to move work from runtime to link 60 time 40 – A jlink plugin to generate some commonly used classes cut the overhead of lambda bootstrap roughly in half 20 0 8 9 Hello Lambda: Hello World Hello Lambda Consumer<String> println = System.out::println; println.accept("Hello World!"); Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | ... and all the way down... ● In JDK 11 we got rid of most of the 140 one-off overheads 120 ● "Hello Lambda" now faster than 100 ) 80 s m ( "Hello World" was on JDK 8 e 60 m i t 40 20 0 8 9 10 11 12 13 Great success! But lambdas aren't Hello World Hello Lambda the only thing that might require expensive bootstrapping... JDK-8198418 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | But first... Compact Strings! ● Enable denser storage of Strings – Internal storage changed from char[] to byte[] Latin 1 – Any string that can be encoded using Before H a l l å Latin 1 will use one byte per character instead of two After H a l l å – Other strings will encode their chars into two bytes as before UTF 16 Before 你 好 ● Obvious footprint wins After 你 好 – Most applications have a significant number of Latin 1 encodable strings ● Surprising(?) throughput improvements https://openjdk.java.net/jeps/254 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Indified String concatenation ● JEP 280 introduced indified String concatenation, ISC @Param("4711") – Use dynamic bootstrapping of String public int intValue; concatenation expressions @Benchmark ● Large throughput and latency wins public String concat() { return "string" + intValue + ● "Most optimal ISC strategies do 2.9x "string" + intValue; better, and 6.4x less garbage" } – Aleksey Shipilëv, JFokus 2016 time alloc ----------------------------- JDK 8 44.0ns/op 80B/op JDK 13 24.5ns/op 64B/op https://openjdk.java.net/jeps/280 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | String Concat Redux ● ISC is cause for some bootstrap overheads of string concatenation expressions in JDK 9 140 ● Some work done before JDK 9 release to 120 lessen the startup blow 100 – The jlink plugin that helped lambda bootstrapping plays a large role here 80 60 40 20 Hello Concat: 0 String foo = ... 8 9 System.out.println("Hello 1: " + foo); Hello World Hello Concat System.out.println("Hello 2: " + foo); ... System.out.println("Hello 10: " + foo); Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | String Concat Redux ● There were some improvements in JDK 10 through 12 for specific cases 140 ● Speeding up bootstrapping of ISC expressions in general proved harder than 120 expected 100 ● Not until JDK 13 did we manage to cut 80 down the overheads more generally 60 40 But we now have a robust framework for 20 building more of these dynamic and 0 performant things into Java (and other JVM 8 9 10 11 12 13 languages) while only paying a small price Hello World Hello Concat for them up front https://cl4es.github.io/2019/05/14/String-Concat-Redux.html Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | And now for something completely different... Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | The G1 garbage collector saw a lot of improvements ● G1 was still lagging behind ParallelGC 1.4 – 1.2 At least on throughput-oriented ) r e t t 1 benchmarks! e b s i r e 0.8 ● h g Over the course of 8 updates and more i h ( e 0.6 r recent releases, the gap has been o c s e shrinking v 0.4 i t a l e ● Just being a few percent behind on R 0.2 throughput is great for a GC that is meant 0 to optimize more for latency! 8 GA 8u231 13 SPECjbb2005 G1 SPECjbb2005 Parallel GC SPECjbb®2005 is a registered trademark of the Standard Performance Evaluation Corporation ( spec.org). The actual results are not represented as compliant because the SUT may not meet SPEC's requirements for general availability. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | The G1 garbage collector saw a lot of improvements Startup Time 250 ● A great number of issues affecting startup time in G1 was addressed 200 150 ) – s m Getting parity on out-of-the-box with ( e m 100 i simpler GCs t – Cutting minutes off of startup in 50 extremer cases (> 1TB heap) 0 8u221 13 Hello World G1 Hello World Parallel GC The numbers shown may somewhat exaggerate the startup overhead when running G1 on 8, since some of it was related to an issue with unnecessary delays when shutting down the JVM Copyright © 2019, Oracle and/or its affiliates.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    43 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us