Skip to content

Commit

Permalink
Merge pull request #323 from graalvm/archive-demos-4
Browse files Browse the repository at this point in the history
[GR-60094] Review and move native-image-configure-examples to archive.
  • Loading branch information
olyagpl authored Dec 17, 2024
2 parents 220a27e + 33e41e7 commit 6161664
Show file tree
Hide file tree
Showing 23 changed files with 19 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
name: native-image-configure-examples
name: archive/class-initialization-examples
on:
push:
paths:
- 'native-image-configure-examples/**'
- '.github/workflows/native-image-configure-examples.yml'
- 'archive/class-initialization-examples/**'
- '.github/workflows/archive-class-initialization-examples.yml'
pull_request:
paths:
- 'native-image-configure-examples/**'
- '.github/workflows/native-image-configure-examples.yml'
schedule:
- cron: "0 0 1 * *" # run every month
- 'archive/class-initialization-examples/**'
- '.github/workflows/archive-class-initialization-examples.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
run:
name: Run 'native-image-configure-examples'
name: Run 'archive/class-initialization-examples'
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
java-version: ['21', 'latest-ea']
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java-version }}
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Run 'configure-at-runtime-example'
run: |
cd native-image-configure-examples/configure-at-runtime-example
cd archive/class-initialization-examples/configure-at-runtime-example
mvn --no-transfer-progress package
./target/runtime-example
- name: Run 'configure-at-buildtime-example'
run: |
cd native-image-configure-examples/configure-at-buildtime-example
cd archive/class-initialization-examples/configure-at-buildtime-example
mvn --no-transfer-progress package
./target/buildtime-example
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ cd graalvm-demos
<td align="left" width="70%">Demonstrates how the Graal compiler can achieve better performance for highly abstracted programs like those using Streams, Lambdas<br><strong>Technologies: </strong>Graal compiler, C2<br><strong>Reference: </strong><a href="https://luna.oracle.com/lab/d502417b-df66-45be-9fed-a3ac8e3f09b1/steps#task-2-run-demos-java-microbenchmark-harness-jmh">Simple Java Stream Benchmark</a></td>
</tr>
<tr>
<td align="left" width="30%"><a href="/native-image-configure-examples/">native-image-configure-examples</a><br><a href="/~https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml"><img alt="streams" src="/~https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml/badge.svg" /></a></td>
<td align="left" width="70%">Demonstrates how you can influence the classes initialization at the image build time<br><strong>Technologies: </strong>Native Image, Maven<br><strong>Reference: </strong><a href="https://medium.com/graalvm/understanding-class-initialization-in-graalvm-native-image-generation-d765b7e4d6ed">Understanding Class Initialization in GraalVM Native Image Generation</a></td>
<td align="left" width="30%"><a href="/multithreading-demo/">multithreading-demo</a><br><a href="/~https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml"><img alt="streams" src="/~https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml/badge.svg" /></a></td>
<td align="left" width="70%">Demonstrates how to optimize a Java application that does synchronous and asynchronous threads execution<br><strong>Technologies: </strong>Native Image Build Reports, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://medium.com/graalvm/making-sense-of-native-image-contents-741a688dab4d">Making sense of Native Image contents</a></td>
</tr>
<tr>
<td align="left" width="30%"><a href="/javagdbnative/">javagdbnative</a><br><a href="/~https://github.com/graalvm/graalvm-demos/actions/workflows/javagdbnative.yml"><img alt="javagdbnative" src="/~https://github.com/graalvm/graalvm-demos/actions/workflows/javagdbnative.yml/badge.svg" /></a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ In both examples we use the Jackson framework to parse a JSON file to determine

1. Download and install the latest GraalVM JDK using [SDKMAN!](https://sdkman.io/).
```bash
sdk install java 21.0.1-graal
sdk install java 21.0.5-graal
```

2. Download or clone the repository and navigate into the `native-image-configure-examples` directory:
2. Download or clone the repository and navigate into the `class-initialization-examples` directory:
```bash
git clone /~https://github.com/graalvm/graalvm-demos
```
```bash
cd graalvm-demos/native-image-configure-examples
cd graalvm-demos/archive/class-initialization-examples
```

## Build and Run Examples

1. Change to one of the demo subdirectories, for example, `configure-at-runtime-example`:
```bash
cd graalvm-demos/native-image-configure-examples/configure-at-runtime-example
cd configure-at-runtime-example
```
2. Build the project:
```bash
mvn package
```
3. Once the Maven build succeeds, a native executable called "runtime-example" will be generated in the `configure-at-runtime-example/target/` directory. Run it:
3. Once the Maven build succeeds, a native executable called "runtime-example" will be generated in the _configure-at-runtime-example/target/_ directory. Run it:
```bash
./target/runtime-example
```
Expand All @@ -63,7 +63,4 @@ In both examples we use the Jackson framework to parse a JSON file to determine

Loading application configuration at executable build time can speed up application startup.

### Related Documentation

- [Build-Time Initialization](https://www.graalvm.org/latest/reference-manual/native-image/optimizations-and-performance/ClassInitialization/)
- [Initialize Once, Start Fast: Application Initialization at Build Time](http://www.christianwimmer.at/Publications/Wimmer19a/Wimmer19a.pdf)
Learn more about [Class Initialization in Native Image](https://www.graalvm.org/latest/reference-manual/native-image/optimizations-and-performance/ClassInitialization/) at the website, and from the blog post [Understanding Class Initialization in GraalVM Native Image Generation](https://medium.com/graalvm/understanding-class-initialization-in-graalvm-native-image-generation-d765b7e4d6ed).
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.10.2</native.maven.plugin.version>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<jackson.version>2.16.0</jackson.version>
</properties>

Expand Down Expand Up @@ -83,9 +83,6 @@
<configuration>
<skip>false</skip>
<imageName>buildtime-example</imageName>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.10.2</native.maven.plugin.version>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<jackson.version>2.16.0</jackson.version>
</properties>

Expand Down Expand Up @@ -83,9 +83,6 @@
</executions>
<configuration>
<imageName>runtime-example</imageName>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 6161664

Please sign in to comment.