Upgrade to Pro — share decks privately, control downloads, hide ads and more …

To the Moon and Beyond With Java 17 APIs!

Gunnar Morling
September 28, 2021

To the Moon and Beyond With Java 17 APIs!

Since moving to a 6 monthly release cadence, the Java platform is evolving more dynamically than ever before. It can be quite a challenge to stay on top of all the changes and new features.

In this talk we're going to explore the most important developments in the Java API: which classes have been added, what has been removed? Join Duke, the Java mascot for a trip to space and learn which exciting new APIs provided by the Java platform can help him with his journey:

- The Java Vector API for utilizing the SIMD capabilities of modern CPU architectures
- The Foreign Linker API for integrating with native code
- The JFR Event Streaming API for publishing JDK Flight Recorder Events

We'll also take a look at some useful changes to the Java runtime, such as CDS archives for a faster spaceship..., uhm, application launch.

Gunnar Morling

September 28, 2021
Tweet

More Decks by Gunnar Morling

Other Decks in Technology

Transcript

  1. To the Moon and Beyond With Java 17 APIs! Gunnar

    Morling Software Engineer, Red Hat @gunnarmorling
  2. #Java17APIs @gunnarmorling “Commit [ourselves] to achieving the goal, before this

    decade talk is out, of landing a man Duke on the Moon and returning him safely to the Earth” Today’s Mission John F. Kennedy
  3. #Java17APIs @gunnarmorling • Projects ◦ Debezium ◦ Quarkus ◦ Hibernate

    • MapStruct, JfrUnit, kcctl • Java Champion • @gunnarmorling Gunnar Morling Open Source Software Engineer at Red Hat
  4. #Java17APIs @gunnarmorling “Introduce an API to express vector computations that

    reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.” The Vector API JEPs 338 / 414 / 417 JEP 417
  5. #Java17APIs @gunnarmorling The Vector API Goals Clear and concise API

    1 Reliable runtime compilation and performance on x64 (SSE, AVX) and AArch64 (NEON, SVE) 2 3 4 Platform agnostic Graceful degradation
  6. #Java17APIs @gunnarmorling The Vector API Use Cases • Image, text,

    signal processing • Encryption • Machine Learning • etc.
  7. #Java17APIs @gunnarmorling The Vector API FizzBuzz – Performance Benchmark Mode

    Cnt Score Error Units scalarFizzBuzz thrpt 5 2204774,792 ± 76581,374 ops/s simdFizzBuzz thrpt 5 8830433,250 ± 69955,161 ops/s MacBook Pro 2019 (2,6 GHz 6-Core Intel Core i7, 32GB RAM)
  8. #Java17APIs @gunnarmorling The Vector API Examining Native Assembly "conditionally copies

    byte elements from the source operand to the destination operand depending on mask bits defined in the implicit third register argument" felixcloutier.com
  9. #Java17APIs @gunnarmorling • Accessing native Memory (JEP 383) • Accessing

    native APIs (JEP 389) ◦ Moving specific parts to native code ◦ Using existing native libraries • Vector API Projekt Panama Integration of JVM and Native Code
  10. #Java17APIs @gunnarmorling • Provide or create header file • Generate

    binding (Panama EA build required) Foreign Linker API jextract
  11. #Java17APIs @gunnarmorling • RMI Activation • Pack 200 • Nashorn

    JavaScript-Engine • Deprecated for Removal in Java 17 ◦ Applet API ◦ Security Manager Detour: Removed APIs Tackling the Maintenance Burden → 🤷 → 🤷 → Standalone Nashorn (ab Java 15), GraalJS
  12. #Java17APIs @gunnarmorling OpenJDK Flight Recorder • “JVM framework for troubleshooting,

    monitoring and profiling” • 150+ built-in event types • Support for custom events • Open source since Java 11 • Meant for “Always on” usage in production
  13. #Java17APIs @gunnarmorling JFR Event Streaming JEP 349 • Processing JFR

    events in “real-time” • Use Cases ◦ Export to monitoring services ◦ Performance tests (JfrUnit) ◦ Predictive analytics
  14. #Java17APIs @gunnarmorling • Performance tests based on metrics like latency/throughput

    often unstable • JfrUnit ◦ Assertions based on proxy metrics ◦ Plain JUnit-Tests ◦ Analysis via JDK Mission Control JFR Event Streaming Use Case: Performance Regression Tests with JfrUnit “Unit testing, for performance”
  15. #Java17APIs @gunnarmorling • Class Data Sharing: Memory mapped class metadata

    • Default CDS archive for JDK classes since Java 12 (JEP 341) • AppCDS: CDS archive for your own classes Detour: Faster Start-up with AppCDS No Need to Go Native?
  16. #Java17APIs @gunnarmorling Detour: AppCDS Quarkus App – Time to First

    Response Hetzner Cloud CX4 (4 vCPUs, 16GB RAM)
  17. #Java17APIs @gunnarmorling Java 17 – An Update Well Worth It!

    Many Improvements Across the Board... Language API Runtime
  18. #Java17APIs @gunnarmorling • Shenandoah GC • JFR support for native

    GraalVM binaries • AArch64/Linux port • Project Lilliput Red Hat & OpenJDK Multiple Contributions
  19. #Java17APIs @gunnarmorling • JEP Search https://chriswhocodes.com/jepsearch.html • Blog (Vector API,

    JFR Event Streaming, AppCDS, etc.) https://www.morling.dev/ • JfrUnit https://github.com/moditect/jfrunit Resources