Slide 1

Slide 1 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 1 Cédric Champeau Oracle Social: @[email protected] Integrating Python and Java easily Using (Micronaut) GraalPy

Slide 2

Slide 2 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 2 About me - Working at Oracle Labs on Micronaut - Main focus on build plugins and dev productivitity - Formerly working at Gradle Inc - Author of static compiler of Groovy - Amateur astronomer https://www.astrobin.com/users/melix/ - Mastodon: @[email protected]

Slide 3

Slide 3 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 3 About Micronaut - Micronaut is focused on modern architectures like Serverless and Microservices - Also a complete framework for any type of application - Lightweight, reactive (HTTP Client/Server based on Netty) - Annotation processor to compute framework infrastructure at compile time

Slide 4

Slide 4 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 4 Micronaut: Build Time Framework Infrastructure Micronaut computes: - All dependency & configuration injection - Annotation metadata, meta-annotations - AOP proxies - Bean introspections - And all other framework infrastructure - Reflection, runtime proxy, and dynamic classloader free

Slide 5

Slide 5 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 5 Micronaut modules Interesting Micronaut modules: - Micronaut Data: AoT compilation of repositories, queries, build time validation with lightweight runtime - Micronaut Sourcegen: language-neutral API for source code generation, replacement for Lombok - Micronaut Serialization: doesn’t use reflection and allows using common annotation models including Jackson annotations, JSON-B annotations or BSON annotations - Micronaut Langchain4j: thin layer over langchain4j

Slide 6

Slide 6 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 6 GraalVM - High-performance JDK distribution - Increases application throughput, reduces latency, reduces memory use - Graal just-in-time (JIT) compiler that runs on top of HotSpot, written in Java - native-image ahead-of-time (AoT) compiler compiles Java applications into small self-contained native binaries

Slide 7

Slide 7 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 7 GraalVM Polyglot

Slide 8

Slide 8 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 8 GraalJS, GraalPy and GraalWasm - Open Source, maintained by GraalVM team - Can run on any OpenJDK distribution - Faster on GraalVM (using Graal compiler) - Supports native image - Plugins for Maven and Gradle

Slide 9

Slide 9 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 9 GraalPy guides and resources https://www.graalvm.org/python/

Slide 10

Slide 10 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 10 Integrating with build tools

Slide 11

Slide 11 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 11 Demo time!

Slide 12

Slide 12 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 12 GraalPy plugin - Available for Maven and Gradle - Supports venv creation and packaging

Slide 13

Slide 13 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 13 Micronaut Graal Languages - Initially supports Python - Exposes Python modules as beans - Deals with context creation boilerplate - Limitation: no multi-context execution

Slide 14

Slide 14 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 14 Pros and Cons Microservices ● ± Independent processes ● - Inter process communcation overhead ● - Data copy / synchronization / file I/O ● + Free to use language runtime for each service Embedded Graal Languages ● + All-in-one process, simple deployment ● + Low-overhead calls between languages ● + Direct data sharing ● - Limited to available runtimes and versions of Graal languages ● - Native libs sometimes hard to support

Slide 15

Slide 15 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 15 Threading model ● Python has a single thread execution lock ● Multiple threads in Java → have to wait for lock – Simple but low throughput ● Solution: context pooling (each context is independent) ● Beware: not compatible with some Python native libraries!

Slide 16

Slide 16 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 16 So what’s the catch? ● Many Python libraries are actually native (C) ● Need to recompile Python packages ● Can be slow, or sometimes fail (e.g no Tensorflow for now) ● Team is working on precompiled wheels (published to Maven Central or something else)

Slide 17

Slide 17 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 17 Compatibility ● Supports Python 3.11 (3.12 in progress) ● Easy upgrade from Jython ● Compatible with the top 500 packages on PyPi – See graalvm.org/python/compatibility ● Native extensions have to be rebuild from source

Slide 18

Slide 18 text

06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential: Internal 18 Resources ● GraalPy Quickstart and Guides: https://www.graalvm.org/python/ ● Demos: https://github.com/graalvm/graal-languages-demos/ ● Micronaut GraalPy: https://micronaut-projects.github.io/micronaut-graal-languages/latest/guide/