Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]

With the recent open-sourcing of JDK Mission Control, there is even more interest in Java Mission Control and Java Flight Recorder than ever. A lot has changed, but these tools still remain on the forefront of debugging and troubleshooting Java issues, both during development and in production. This session covers these recent changes, migrating from earlier versions, and what the JDK Mission Control community’s plans are for the future.

  • Login to see the comments

  • Be the first to like this

JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]

  1. 1. Copyright © 2019 Oracle and/or its affiliates.
  2. 2. 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, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website at http://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Safe Harbor Copyright © 2019 Oracle and/or its affiliates.
  3. 3. JDK Mission Control: Where We Are, Where We Are Going Principal Member of Technical Staff Java Platform Group September 16, 2019 David Buck Copyright © 2019 Oracle and/or its affiliates.
  4. 4. JVM Sustaining Engineer OpenJDK 8 Update Project Maintainer JavaOne Rock Star Co-author of Oracle WebLogic Server 11g 構築・運用ガイド @DavidBuckJP https://blogs.oracle.com/buck/ Who am I? David Buck (left)
  5. 5. • Background / History • Building • Demo • Takaways Copyright © 2019 Oracle and/or its affiliates. Agenda
  6. 6. Introduction to JDK Mission Control and JDK Flight Recorder [DEV2316] Marcus Hirt and Klara Ward Monday 16:00 Moscone South Room 202 Improving Observability in Your Application with JFR and JMC [DEV3460] Marcus Hirt and Mario Torre Tuesday 11:30 Moscone South Room 201 Java Flight Recorder: Black Box of Java Applications[DEV3957] Poonam Parhar Wednesday 12:30 Moscone South Room 203 Robotics on JDK 11? With Modules? Are You… [DEV2329] Marcus Hirt, Miro Wengner, and Robert Savage Wednesday 16:00 Moscone South Room 313 Four Productive Ways to Use Open Source JFR and JMC Revisited [DEV3118] Sven Reimers and Martin Klähn Thursday 11:15 Moscone South Room 304 Enhanced Java Flight Recorder at Alibaba [DEV3667] Sanhong Li, Fangxi Yin, and Guangyu Zhu Thursday 12:15 Moscone South Room 203 Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406] Hirofumi Iwasaki and Hiroaki Nakada Thursday 13:15 Moscone South Room 201
  7. 7. Introduction to JDK Mission Control and JDK Flight Recorder [DEV2316] Marcus Hirt and Klara Ward Monday 16:00 Moscone South Room 202 Improving Observability in Your Application with JFR and JMC [DEV3460] Marcus Hirt and Mario Torre Tuesday 11:30 Moscone South Room 201 Java Flight Recorder: Black Box of Java Applications[DEV3957] Poonam Parhar Wednesday 12:30 Moscone South Room 203 Robotics on JDK 11? With Modules? Are You… [DEV2329] Marcus Hirt, Miro Wengner, and Robert Savage Wednesday 16:00 Moscone South Room 313 Four Productive Ways to Use Open Source JFR and JMC Revisited [DEV3118] Sven Reimers and Martin Klähn Thursday 11:15 Moscone South Room 304 Enhanced Java Flight Recorder at Alibaba [DEV3667] Sanhong Li, Fangxi Yin, and Guangyu Zhu Thursday 12:15 Moscone South Room 203 Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406] Hirofumi Iwasaki and Hiroaki Nakada Thursday 13:15 Moscone South Room 201
  8. 8. Background
  9. 9. Several Closely Related Technologies (JRockit / Java / JDK) Mission Control Flight Recording Oracle JDK: JDK 7 OpenJDK: JDK 11 JEP 167: Event-Based JVM Tracing (JDK 7) JEP 328: Flight Recorder (JDK 11)
  10. 10. Flight Recorder Technology to generate and persist JVM event data Low-overhead Intended for use in production Viable for “always on” use-case
  11. 11. Mission Control Eclipse-based (RCP) GUI tool Visualization of Flight Recording data Automated Flight Recording analysis JMX console for real-time monitoring (and control) of target Plug-in framework for additional functionality Support for integration into Eclipse IDE
  12. 12. Mission Control Eclipse-based (RCP) GUI tool Visualization of Flight Recording data Automated Flight Recording analysis JMX console for real-time monitoring (and control) of target Plug-in framework for additional functionality Support for integration into Eclipse IDE
  13. 13. History
  14. 14. Our Story Begins in Sweden By Holger.Ellgaard - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=5623391
  15. 15. JRockit Developed by Stockholm-based Appeal Virtual Systems JIT-only JVM (no interpreter) Heavily focused on Intel (x86 / AMD64 / IA64) performance
  16. 16. Value Add JRockit was originally sold as a “Virtual Machine for Java” Sun required each Java licensee to have a “value add” “Superior performance” didn’t go over well... JRockit’s monitoring and management tools were presented as its value add to differentiate itself from Sun’s offerings
  17. 17. Alex Flury at English Wikipedia [Public domain]
  18. 18. By VARA - Beeld- en Geluidwiki, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=49198465
  19. 19. Appeal Virtual Machines
  20. 20. 2002
  21. 21. Appeal Virtual Machines BEA Systems
  22. 22. BEA Systems
  23. 23. 2008
  24. 24. BEA Systems
  25. 25. BEA Systems
  26. 26. 2009
  27. 27. A Combined Legacy JRockit’s best features ported over to HotSpot Diagnostic commands (JDK 7) Compiler control (JDK 9) Native memory tracking (JDK 7) Flight Recorder (JDK 7) Build system (behind the scenes) (JDK 8) JRockit Mission Control -> Java Mission Control
  28. 28. JRockit Mission Control 1
  29. 29. JRockit Runtime Analyzer Based on experience gained while consulting “Cast a big net” to avoid multiple support iterations Most data collection piggy-backed onto internal JVM operations (low overhead) Data persisted at zipped XML
  30. 30. JRockit Mission Control 2
  31. 31. JRockit Mission Control 3
  32. 32. JRockit Mission Control 4 Post Oracle acquisition (JRockit R28) Flight Recorder replaces JRockit Runtime Analyzer XML data -> binary data Much lower overhead to collect and persist data
  33. 33. Java Mission Control 5
  34. 34. Flight Recorder in HotSpot Flight Recorder support added in 7u40 JMC 5 bundled with JDK
  35. 35. JDK 7 JMC 5 JDK 8 JMC 5.5 JDK 9 JMC 6 JDK 10 JMC 6
  36. 36. 2018
  37. 37. JDK Mission Control 7 Open source No longer bundled with JDK (as of JDK 11) Flight Recorder implementation open sourced (as of JDK 11)
  38. 38. Universal Permissive License Clear patent protection Clear & simplified relicensing Reduced overhead in source files It can be used as a contributor agreement See FAQ (link at end of slide deck) for details
  39. 39. Universal Permissive License Clear patent protection Clear & simplified relicensing Reduced overhead in source files It can be used as a contributor agreement See FAQ (link at end of slide deck) for details
  40. 40. Oracle Contributor Agreement Must be signed and sent to Oracle to contribute code to Mission Control Same requirement as other OpenJDK projects Only needs to be done once
  41. 41. “...you're doing an awesome job in building a real community and a *very* open source project.“ - Red Hat Contributor to Marcus Hirt jmc-dev alias, November 8, 2018
  42. 42. Compatibility Flight Recording format changes between JDK versions Mission Control has always been backwards compatible with flight recordings from older HotSpot releases. JDK 11 requires JMC 7 JMC 7 is currently the only version that supports all HotSpot based flight recordings
  43. 43. Building
  44. 44. Requirements Mercurial (hg) Maven JDK 8
  45. 45. OpenJDK JMC repositories jmc Mainline Development Branch jmc-graphics images / branding resources jmc7 JMC 7.0 branch Copyright © 2019 Oracle and/or its affiliates.
  46. 46. GitHub Mirror Only mainline development branch Not in full sync at the moment Recommend using hg until project Skara migration * * Maybe...
  47. 47. A Tale of Two Shells... Shell 1 cd releng/third-party mvn p2:site mvn jetty:run Shell 2 cd core mvn install cd .. mvn clean package
  48. 48. A Tale of Two Shells... Equinox p2: provisioning platform for OSGi artifacts and meta-data Shell 1 sets up a p2 repository that hosts dependencies needed by the build process run in shell 2
  49. 49. Cross Compilation?! Regardless of build platform, binaries for all three target platforms are generated Platform-dependent bits are downloaded as dependencies
  50. 50. Building Quick and easy to do Builds virtually out of the box on most Linux distros Build platform does not need to match target platform
  51. 51. Demo
  52. 52. Safepoints Stop-the-World implementation Guarantees Java state of thread is known All threads executing Java code must stop JNI code can continue Cooperative suspension Polling based By YPLeroux at English Wikipedia, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=17734859
  53. 53. Safepoints Stop-the-World implementation Guarantees Java state of thread is known All threads executing Java code must stop JNI code can continue Cooperative suspension Polling based By YPLeroux at English Wikipedia, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=17734859
  54. 54. Safepoint Polling Interpreter can stop instantly template dispatch table replaced “polling” is essentially free Explicit poll inserted into C1/C2 JIT output Global safepoint polling page in address space Poll implemented by attempted read of this address Safepoint triggered by change in page permissions
  55. 55. JIT Safepoint Polling On return from method call Backend branches in most loops Any transition to native code (JVM / JNI)
  56. 56. Collatz Conjecture Simple rules: If number is even, divide by 2 If number is odd, multiply by 3 and add 1 Conjecture: Start with any positive integer, and you’ll eventually end up at 1 An open problem in math
  57. 57. Collatz Conjecture Examples 2 1 3 10 5 16 8 4 2 1 4 2 1 5 16 8 4 2 1 6 3 10 5 16 8 4 2 1 7 22 11 34 17 52 26 13 40 20 10 5 16 8...
  58. 58. Collatz Conjecture Examples 2 1 3 10 5 16 8 4 2 1 4 2 1 5 16 8 4 2 1 6 3 10 5 16 8 4 2 1 7 22 11 34 17 52 26 13 40 20 10 5 16 8...
  59. 59. Collatz Conjecture By Kunashmilovich - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=48786325
  60. 60. Let’s test the Collatz Conjecture...
  61. 61. Let’s test the Collatz Conjecture... the stupidest way imaginable!
  62. 62. Testing the Collatz Conjecture private static long next(long num) { return (num%2 == 0) ? num / 2 : 3 * num + 1; }
  63. 63. Testing the Collatz Conjecture public static void main(String[] args) { long num; for (int i=2; i < Integer.MAX_VALUE; i++) { num = i; for (int j=0; j < Integer.MAX_VALUE; j++) { num = next(num); if (num == 1) break; } if (num != 1) { System.out.println(i + " did not end at 1."); System.exit(-1); } else if (i % 1000000 == 0) { System.out.println("done with " + i); } } }
  64. 64. Counted Loop Loop that increments / decrements an int index Worst case scenario, we loop 4 billion times (very short) HotSpot may not bother adding a safepoint pool to the loop
  65. 65. Testing the Collatz Conjecture public static void main(String[] args) { long num; for (int i=2; i < Integer.MAX_VALUE; i++) { num = i; for (int j=0; j < Integer.MAX_VALUE; j++) { num = next(num); if (num == 1) break; } if (num != 1) { System.out.println(i + " did not end at 1."); System.exit(-1); } else if (i % 1000000 == 0) { System.out.println("done with " + i); } } }
  66. 66. Testing the Collatz Conjecture public static void main(String[] args) { long num; for (int i=2; i < Integer.MAX_VALUE; i++) { num = i; for (int j=0; j < Integer.MAX_VALUE; j++) { num = next(num); if (num == 1) break; } if (num != 1) { System.out.println(i + " did not end at 1."); System.exit(-1); } else if (i % 1000000 == 0) { System.out.println("done with " + i); } } }
  67. 67. Profiler Types Sampling Profiler Process sampled periodically Invocation count is not exact Observer effect should be negligible Invocation Counter Profiler Code is instrumented Exact number of invocations Observer effect often distorts results
  68. 68. Profiler Types Sampling Profiler Process sampled periodically Invocation count is not exact Observer effect should be negligible Invocation Counter Profiler Code is instrumented Exact number of invocations Observer effect often distorts results
  69. 69. Traditional Sampler JVMTI / Bytecode instrumentation can only stop thread at a safepoint poll What happens between safpoint polls is invisible to the profiler
  70. 70. VisualVM
  71. 71. Flight Recording Can asynchronously stop execution thread at any time No dependence on safe points for profiling HotSpot internal API (AsyncGetCallTrace) Honest Profiler Oracle Developer Studio
  72. 72. Flight Recorder Mission Control
  73. 73. What happened? Safepoints have corresponding metadata Byte Code Index (bci) Liveness data (what stack positions point to Java heap)
  74. 74. What happened? By default, metadata is normally only generated for safepoints DebugNonSafepoints flag forces metadata generation for all code (obvious performance cost)
  75. 75. Flight Recorder Mission Control
  76. 76. Flight Recorder Mission Control
  77. 77. Takeaways Open sourcing of JMC has been a great success JMC 7 and higher are the ideal MC to use regardless of JDK version Binary builds from Oracle should be available in the near future JMC is simple to build on your own today Flight Recording’s AsyncGetCallTrace-based profiling can provide a level of accuracy unachievable by most other tools.
  78. 78. Thank You!
  79. 79. References Marcus Hirt’s Blog http://hirt.se/blog/ The Universal Permissive License (UPL) https://oss.oracle.com/licenses/upl/
  80. 80. Session Survey Help us make the content even better. Please complete the session survey in the Mobile App. Copyright © 2019 Oracle and/or its affiliates.
  81. 81. The preceding 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, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website at http://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Safe Harbor Copyright © 2019 Oracle and/or its affiliates.

×