Skip to content

Commit

Permalink
Merge pull request #322 from graalvm/archive-demos-3
Browse files Browse the repository at this point in the history
[GR-60094] Review and move multithreading-demo demo to archive.
  • Loading branch information
olyagpl authored Dec 17, 2024
2 parents 60905ec + 7c125d3 commit 773dab2
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
name: multithreading-demo
name: archive/multithreading-demo
on:
push:
paths:
- 'multithreading-demo/**'
- '.github/workflows/multithreading-demo.yml'
- 'archive/multithreading-demo/**'
- '.github/workflows/archive-multithreading-demo.yml'
pull_request:
paths:
- 'multithreading-demo/**'
- '.github/workflows/multithreading-demo.yml'
schedule:
- cron: "0 0 1 * *" # run every month
- 'archive/multithreading-demo/**'
- '.github/workflows/archive-multithreading-demo.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
run:
name: Run 'multithreading-demo'
name: Run 'archive/multithreading-demo'
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
java-version: ['22', '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 'multithreading-demo-oversized'
run: |
cd multithreading-demo/multithreading-demo-oversized
cd archive/multithreading-demo/multithreading-demo-oversized
mvn --no-transfer-progress package
java -jar target/multithreading-1.0-jar-with-dependencies.jar
./target/multithreading-image-oversized
- name: Run 'multithreading-demo-improved'
run: |
cd multithreading-demo/multithreading-demo-improved
cd archive/multithreading-demo/multithreading-demo-improved
mvn --no-transfer-progress package
java -jar target/multithreading-1.0-jar-with-dependencies.jar
./target/multithreading-image-improved
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ cd graalvm-demos
<td align="left" width="30%"><a href="/java-simple-stream-benchmark/">java-simple-stream-benchmark</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/java-simple-stream-benchmark.yml"><img alt="java-simple-stream-benchmark" src="https://github.com/graalvm/graalvm-demos/actions/workflows/java-simple-stream-benchmark.yml/badge.svg" /></a></td>
<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="/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="/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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Each thread loops through exactly the same array of integers and generates a str
The program calculates the time taken to perform the task synchronously and asynchronously.

Multithreading demo is comprised of two sub-projects, each built with Maven: **Multithreading Demo Oversized** and **Multithreading Demo Improved**.
The _pom.xml_ file of each sub-project includes the [Native Image Maven plugin](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html), which instructs Maven to generate a native executable of a JAR file with all dependencies at the `mvn package` step.
The _pom.xml_ file of each sub-project includes the [Maven plugin for Native Image building](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html), which instructs Maven to generate a native executable of a JAR file with all dependencies at the `mvn package` step.

The plugin also generates a report using the [Native Image Build Reports](https://www.graalvm.org/latest/reference-manual/native-image/overview/Options/#build-output-and-build-report) feature in the _target_ directory with useful visualizations and comprehensive insights into different metrics of the native executable and the build process itself.

```xml
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.1</version>
<version>${org.graalvm.buildtools.version}</version>
<extensions>true</extensions>
<executions>
<execution>
Expand Down Expand Up @@ -44,15 +44,15 @@ The plugin also generates a report using the [Native Image Build Reports](https:

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

2. Download or clone the repository and navigate into the `multithreading-demo/multithreading-demo-oversized_` directory:
```bash
git clone https://github.com/graalvm/graalvm-demos
```
```bash
cd multithreading-demo/multithreading-demo-oversized
cd graalvm-demos/archive/multithreading-demo/multithreading-demo-oversized
```

## Multithreading Demo Oversized
Expand Down Expand Up @@ -89,6 +89,4 @@ Multithreading Demo Improved contains an enhanced version of the same program.
./target/multithreading-image-improved
```

### Learn More

Learn how you can optimize a Java application by applying Profile-guided optimization (PGO) and inspect a profile using [Native Image Build Reports](https://www.graalvm.org/jdk22/reference-manual/native-image/optimizations-and-performance/PGO/build-reports/).
Continue reading about how you can inspect a profile and potentially optimize size of your native application using [Build Reports](https://www.graalvm.org/latest/reference-manual/native-image/guides/optimize-native-executable-size-using-build-report/).
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<version>1.0</version>

<properties>
<native.maven.plugin.version>0.10.1</native.maven.plugin.version>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencies>
Expand Down Expand Up @@ -87,9 +87,8 @@
<imageName>multithreading-image-improved</imageName>
<fallback>false</fallback>
<buildArgs>
<buildArg>
-H:+UnlockExperimentalVMOptions -H:+BuildReport --initialize-at-build-time
</buildArg>
<buildArg>-H:+UnlockExperimentalVMOptions -H:+BuildReport</buildArg>
<buildArg>--initialize-at-build-time</buildArg>
</buildArgs>
<agent>
<enabled>true</enabled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<version>1.0</version>

<properties>
<native.maven.plugin.version>0.10.1</native.maven.plugin.version>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencies>
Expand Down Expand Up @@ -87,9 +87,8 @@
<imageName>multithreading-image-oversized</imageName>
<fallback>false</fallback>
<buildArgs>
<buildArg>
--no-fallback -H:+UnlockExperimentalVMOptions -H:+BuildReport --initialize-at-build-time
</buildArg>
<buildArg>-H:+UnlockExperimentalVMOptions -H:+BuildReport</buildArg>
<buildArg>--initialize-at-build-time</buildArg>
</buildArgs>
<agent>
<enabled>true</enabled>
Expand Down

0 comments on commit 773dab2

Please sign in to comment.