Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GraalVM Native Image and Truffle compilation sections for GraalPy guides #1563

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ image::graalpy-pygal.png[]

common:graalpy-graalvm.adoc[]

Open `http://localhost:8080/pygal` in a web browser of your choice to execute the
Open http://localhost:8080/pygal[http://localhost:8080/pygal] in your web browser to execute the endpoint exposed by the native executable. You should see a stacked bar chart.
endpoint exposed by the native executable. You should see a stacked bar chart.

== Next Steps
Expand Down
12 changes: 6 additions & 6 deletions src/docs/common/snippets/common-graalpy-graalvm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

== Python Runtime Compilation

With GraalVM JDK, the Python code executed using the GraalPy engine will be just-in-time compiled.
With other JDKs, the Python code will be interpreted, which negatively impacts its performance.
When using the GraalVM JDK, Python code executed with the GraalPy engine is just-in-time compiled.
With other JDKs, the Python code is interpreted, resulting in reduced performance.

The easiest way to install https://www.graalvm.org[GraalVM] on Linux or Mac is to use https://sdkman.io/[SDKMan.io].

Expand All @@ -27,7 +27,7 @@ sdk install java 23-graalce

=== GraalVM JDK Compatibility

In order to support runtime compilation, one must use versions of GraalPy and the Polyglot API
To enable runtime compilation, you must use versions of GraalPy and the Polyglot API dependencies that are compatible with the specified GraalVM JDK version. If you see errors like the following:
dependencies compatible with given GraalVM JDK version. If you see errors like this:
steve-s marked this conversation as resolved.
Show resolved Hide resolved

[source, bash]
Expand All @@ -47,14 +47,14 @@ org.graalvm.python:graalpy-maven-plugin

== Generate a Micronaut Application Native Executable with GraalVM

Starting from the GraalVM for JDK 23, Micronaut applications using GraalPy, or any Truffle language in general,
Starting with GraalVM for JDK 23, Micronaut applications that use GraalPy or any Truffle language can be compiled into native executables using GraalVM Native Image.
can be compiled to native executable using GraalVM Native Image.
steve-s marked this conversation as resolved.
Show resolved Hide resolved

Compiling Micronaut applications ahead of time with GraalVM significantly improves startup time and reduces
the memory footprint of JVM-based applications.

=== Native Executable metadata
steve-s marked this conversation as resolved.
Show resolved Hide resolved
The https://www.graalvm.org/[GraalVM] Native Image compilation requires metadata to properly run code that uses https://www.graalvm.org/latest/reference-manual/native-image/metadata/#dynamic-proxy[dynamic proxies].
GraalVM Native Image compilation requires metadata to correctly run code that uses https://www.graalvm.org/latest/reference-manual/native-image/metadata/#dynamic-proxy[dynamic proxies].

Create a proxy configuration file:
resource:META-INF/native-image/proxy-config.json[]
Expand All @@ -68,4 +68,4 @@ To generate a native executable using Maven, run:
./mvnw package -Dpackaging=native-image
----

The native executable is created in the `target` directory and can be run with `target/micronautguide`.
The native executable is created in the _target_ directory and can be run with `./target/micronautguide`.