From cc9ebf31509f92be92594324150d7fe4f3f25c1a Mon Sep 17 00:00:00 2001 From: Olya Gupalo Date: Mon, 16 Dec 2024 14:38:15 +0200 Subject: [PATCH 1/4] Review and move multithreading-demo to archive --- .../multithreading-demo}/README.md | 12 +++++------- .../multithreading-demo.iml | 0 .../multithreading-demo-improved/pom.xml | 0 .../src/main/java/demo/Multithreading.java | 0 .../src/main/resources/config.json | 0 .../multithreading-demo.iml | 0 .../multithreading-demo-oversized/pom.xml | 0 .../src/main/java/demo/Multithreading.java | 0 .../META-INF/native-image/resource-config.json | 0 .../src/main/resources/config.json | 0 10 files changed, 5 insertions(+), 7 deletions(-) rename {multithreading-demo => archive/multithreading-demo}/README.md (79%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-improved/multithreading-demo.iml (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-improved/pom.xml (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-improved/src/main/java/demo/Multithreading.java (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-improved/src/main/resources/config.json (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-oversized/multithreading-demo.iml (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-oversized/pom.xml (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-oversized/src/main/java/demo/Multithreading.java (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-oversized/src/main/resources/META-INF/native-image/resource-config.json (100%) rename {multithreading-demo => archive/multithreading-demo}/multithreading-demo-oversized/src/main/resources/config.json (100%) diff --git a/multithreading-demo/README.md b/archive/multithreading-demo/README.md similarity index 79% rename from multithreading-demo/README.md rename to archive/multithreading-demo/README.md index 01ab9cd35..3bf773133 100644 --- a/multithreading-demo/README.md +++ b/archive/multithreading-demo/README.md @@ -5,7 +5,7 @@ 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. @@ -13,7 +13,7 @@ The plugin also generates a report using the [Native Image Build Reports](https: org.graalvm.buildtools native-maven-plugin - 0.10.1 + ${org.graalvm.buildtools.version} true @@ -44,7 +44,7 @@ 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: @@ -52,7 +52,7 @@ The plugin also generates a report using the [Native Image Build Reports](https: 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 @@ -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/). \ No newline at end of file +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/). \ No newline at end of file diff --git a/multithreading-demo/multithreading-demo-improved/multithreading-demo.iml b/archive/multithreading-demo/multithreading-demo-improved/multithreading-demo.iml similarity index 100% rename from multithreading-demo/multithreading-demo-improved/multithreading-demo.iml rename to archive/multithreading-demo/multithreading-demo-improved/multithreading-demo.iml diff --git a/multithreading-demo/multithreading-demo-improved/pom.xml b/archive/multithreading-demo/multithreading-demo-improved/pom.xml similarity index 100% rename from multithreading-demo/multithreading-demo-improved/pom.xml rename to archive/multithreading-demo/multithreading-demo-improved/pom.xml diff --git a/multithreading-demo/multithreading-demo-improved/src/main/java/demo/Multithreading.java b/archive/multithreading-demo/multithreading-demo-improved/src/main/java/demo/Multithreading.java similarity index 100% rename from multithreading-demo/multithreading-demo-improved/src/main/java/demo/Multithreading.java rename to archive/multithreading-demo/multithreading-demo-improved/src/main/java/demo/Multithreading.java diff --git a/multithreading-demo/multithreading-demo-improved/src/main/resources/config.json b/archive/multithreading-demo/multithreading-demo-improved/src/main/resources/config.json similarity index 100% rename from multithreading-demo/multithreading-demo-improved/src/main/resources/config.json rename to archive/multithreading-demo/multithreading-demo-improved/src/main/resources/config.json diff --git a/multithreading-demo/multithreading-demo-oversized/multithreading-demo.iml b/archive/multithreading-demo/multithreading-demo-oversized/multithreading-demo.iml similarity index 100% rename from multithreading-demo/multithreading-demo-oversized/multithreading-demo.iml rename to archive/multithreading-demo/multithreading-demo-oversized/multithreading-demo.iml diff --git a/multithreading-demo/multithreading-demo-oversized/pom.xml b/archive/multithreading-demo/multithreading-demo-oversized/pom.xml similarity index 100% rename from multithreading-demo/multithreading-demo-oversized/pom.xml rename to archive/multithreading-demo/multithreading-demo-oversized/pom.xml diff --git a/multithreading-demo/multithreading-demo-oversized/src/main/java/demo/Multithreading.java b/archive/multithreading-demo/multithreading-demo-oversized/src/main/java/demo/Multithreading.java similarity index 100% rename from multithreading-demo/multithreading-demo-oversized/src/main/java/demo/Multithreading.java rename to archive/multithreading-demo/multithreading-demo-oversized/src/main/java/demo/Multithreading.java diff --git a/multithreading-demo/multithreading-demo-oversized/src/main/resources/META-INF/native-image/resource-config.json b/archive/multithreading-demo/multithreading-demo-oversized/src/main/resources/META-INF/native-image/resource-config.json similarity index 100% rename from multithreading-demo/multithreading-demo-oversized/src/main/resources/META-INF/native-image/resource-config.json rename to archive/multithreading-demo/multithreading-demo-oversized/src/main/resources/META-INF/native-image/resource-config.json diff --git a/multithreading-demo/multithreading-demo-oversized/src/main/resources/config.json b/archive/multithreading-demo/multithreading-demo-oversized/src/main/resources/config.json similarity index 100% rename from multithreading-demo/multithreading-demo-oversized/src/main/resources/config.json rename to archive/multithreading-demo/multithreading-demo-oversized/src/main/resources/config.json From 1ccbf10f64ba7095c233f2f27c83661dbd1f7717 Mon Sep 17 00:00:00 2001 From: Olya Gupalo Date: Mon, 16 Dec 2024 14:41:19 +0200 Subject: [PATCH 2/4] Update CI workflow to not run montly; Remove demo entry from top-level README --- ...mo.yml => archive-multithreading-demo.yml} | 23 ++++++++----------- README.md | 4 ---- 2 files changed, 9 insertions(+), 18 deletions(-) rename .github/workflows/{multithreading-demo.yml => archive-multithreading-demo.yml} (61%) diff --git a/.github/workflows/multithreading-demo.yml b/.github/workflows/archive-multithreading-demo.yml similarity index 61% rename from .github/workflows/multithreading-demo.yml rename to .github/workflows/archive-multithreading-demo.yml index 7310fc3c9..3f23a72f7 100644 --- a/.github/workflows/multithreading-demo.yml +++ b/.github/workflows/archive-multithreading-demo.yml @@ -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 diff --git a/README.md b/README.md index 73157cf45..c98188f80 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,6 @@ cd graalvm-demos java-simple-stream-benchmark
java-simple-stream-benchmark Demonstrates how the Graal compiler can achieve better performance for highly abstracted programs like those using Streams, Lambdas
Technologies: Graal compiler, C2
Reference: Simple Java Stream Benchmark - - multithreading-demo
streams - Demonstrates how to optimize a Java application that does synchronous and asynchronous threads execution
Technologies: Native Image Build Reports, Native Build Tools Maven plugin
Reference: Making sense of Native Image contents - native-image-configure-examples
streams Demonstrates how you can influence the classes initialization at the image build time
Technologies: Native Image, Maven
Reference: Understanding Class Initialization in GraalVM Native Image Generation From 9d955497549d7f5d05d1f6f26ac913d4fdb5c16a Mon Sep 17 00:00:00 2001 From: Olya Gupalo Date: Mon, 16 Dec 2024 14:44:44 +0200 Subject: [PATCH 3/4] Fix compiler target version --- .../multithreading-demo-improved/pom.xml | 6 +++--- .../multithreading-demo-oversized/pom.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/archive/multithreading-demo/multithreading-demo-improved/pom.xml b/archive/multithreading-demo/multithreading-demo-improved/pom.xml index 03e6f32ef..abd438a2a 100644 --- a/archive/multithreading-demo/multithreading-demo-improved/pom.xml +++ b/archive/multithreading-demo/multithreading-demo-improved/pom.xml @@ -9,9 +9,9 @@ 1.0 - 0.10.1 - 22 - 22 + 0.10.4 + 21 + 21 diff --git a/archive/multithreading-demo/multithreading-demo-oversized/pom.xml b/archive/multithreading-demo/multithreading-demo-oversized/pom.xml index fda557811..da1319518 100644 --- a/archive/multithreading-demo/multithreading-demo-oversized/pom.xml +++ b/archive/multithreading-demo/multithreading-demo-oversized/pom.xml @@ -9,9 +9,9 @@ 1.0 - 0.10.1 - 22 - 22 + 0.10.4 + 21 + 21 From 7c125d31251ea5cff170812e737d067e34ffc302 Mon Sep 17 00:00:00 2001 From: Olya Gupalo Date: Mon, 16 Dec 2024 14:50:50 +0200 Subject: [PATCH 4/4] Fix options configuration --- .../multithreading-demo/multithreading-demo-improved/pom.xml | 5 ++--- .../multithreading-demo-oversized/pom.xml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/archive/multithreading-demo/multithreading-demo-improved/pom.xml b/archive/multithreading-demo/multithreading-demo-improved/pom.xml index abd438a2a..596ea0076 100644 --- a/archive/multithreading-demo/multithreading-demo-improved/pom.xml +++ b/archive/multithreading-demo/multithreading-demo-improved/pom.xml @@ -87,9 +87,8 @@ multithreading-image-improved false - - -H:+UnlockExperimentalVMOptions -H:+BuildReport --initialize-at-build-time - + -H:+UnlockExperimentalVMOptions -H:+BuildReport + --initialize-at-build-time true diff --git a/archive/multithreading-demo/multithreading-demo-oversized/pom.xml b/archive/multithreading-demo/multithreading-demo-oversized/pom.xml index da1319518..d840f62c9 100644 --- a/archive/multithreading-demo/multithreading-demo-oversized/pom.xml +++ b/archive/multithreading-demo/multithreading-demo-oversized/pom.xml @@ -87,9 +87,8 @@ multithreading-image-oversized false - - --no-fallback -H:+UnlockExperimentalVMOptions -H:+BuildReport --initialize-at-build-time - + -H:+UnlockExperimentalVMOptions -H:+BuildReport + --initialize-at-build-time true