Skip to content

alina-yur/graalvm-in-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GraalVM in Practice

Deep Dive: GraalVM in Practice (recording)

  • GraalVM components 🐰

  • Migrating an app to GraalVM πŸ€– πŸ‘©β€πŸ’» spring-petclinic

    • πŸ‘©β€πŸ’» use Native Build Tools πŸ› οΈ
    • πŸ‘©β€πŸ’» basic performance measurements with time πŸ“ˆ
  • Reflection and Using libraries πŸ“š

    • Basic Use: configuration not needed or automatically provided
      • A library might be designed to be Native-Image friendly out of the box;
      • A library might add config files to its source code;
      • Library configuration can be provided via GraalVM Reachability Metadata Repository;
      • Recommended: use -H:Preserve
      • Recommended: Use Dynamic Access Report
    • Advanced use: programatic or semi-automatic configuration registration
      • You can programmatically generate configuration via framework annotations, such as @ReflectiveAccess πŸ‘©β€πŸ’» native-micronaut-reflection
      • You can use Native Image's Tracing Agent (java -agentlib:native-image-agent -jar ./target/demo.jar)
      • You can provide configuration manually via json
    • Crema
  • Performance optimizations πŸš€

    • Overview of compiler optimization levels
    • πŸ‘©β€πŸ’» PGO πŸ‘©β€πŸ’» spring-petclinic
      • ML-enabled PGO (in -O3)
    • G1 GC πŸ‘©β€πŸ’»
    • -march=native
    • Memory management (xmx)
    • Demo: spring-petclinic
    • Advanced level
      • Flamegraph in build reports πŸ‘©β€πŸ’»
      • You can use LCOV tooling to visualize PGO profiles
        • Build with --pgo-instrument -H:+ProfilingLCOV
        • Run with ./target/spring-petclinic-instrumented-lcov
        • Visualize in the tooling of your choice, e.g. genhtml
        • perf stat ./target/spring-petclinic-optimized`
  • Testing πŸ‘¨β€πŸ”¬

    • You can your tests in the native mode
    • Fine-grained JUnit support for flexibility: @EnabledInNativeImage, @DisabledInNativeImage
    • Specifically test in your CI/CD and when adding new dependencies
    • Look at framework modules, such as Micronaut Test Resources or Quarkus Dev Services
  • Deployment πŸ“¦

    • πŸ‘©β€πŸ’» Packaging and linking options
      • Dynamic linking: smallest binaries, fastest builds, no special toolchain. Needs shared libs provided by the excution platform.
      • Mostly-static: statically links everything except the C standard library (libc). Fewer runtime dependencies, smaller than fully static, but still requires libc and not as portable as fully static.
      • Fully static: fully self-contained, runs on scratch, highly portable. Larger binaries, requires recompiling for both code & patch updates.
      • Demo: πŸ‘©β€πŸ’» native-spring-boot docker images | grep "native-spring"
    • Recipe for the smallest container images: Native | Static | From scratch | Optimize for size
    • You can scan the images for vulnerabilities & packages πŸ›‘οΈ
    • Buildpacks
    • GitHub actions
  • Monitoring πŸ“ˆ

  • GraalVM 25 🐰

    • Zero configuration migration with -H:Preserve=all
    • Taking it one step further: use the new tracing agent to produce precise configuration with -XX:TraceMetadata=path=
    • Security πŸ›‘οΈ
      • Security by design and by default
      • SBOM options: --enable-sbom=[embed|export|classpath|class-level]
        • πŸ‘©β€πŸ’» Vulnerability Scanning
        • grype: native-image-inspect --sbom ./target/demo-sbom | grype -v
      • πŸ‘©β€πŸ’» SBOM support: exposing in Spring Actuator
      • Demo: native-spring-boot-sbom
      • Adavanced obfuscation: -H:AdvancedObfuscation=
    • Tooling: Build reports πŸ› οΈ
    • Refined ML profile inference for even higher performance out of the box, on by default in -03
      • Enable in -O2: -H:+MLProfileInferenceUseGNNModel
    • Use ML for smaller executables: -H:+MLCallCountProfileInference
    • Fast PIE with -H:+RelativeCodePointers native-micronaut-reflection
    • FFM and Vector API support updates
    • DX updates πŸ› οΈ
    • Embedding Python πŸ‘©β€πŸ’» airline-demo
  • Future work πŸ‘©β€πŸ”¬

About

GraalVM Deep Dive for Devoxx Belgium

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published