Skip to content

Commit

Permalink
Added PMO optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Jun 19, 2024
1 parent 0a7fc10 commit d5db671
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 18 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,11 @@ One of the most powerful performance optimizations in Native Image is profile-gu
1. Build an instrumented image:

```shell
mvn package -Dnative -Pinstrumented
mvn package -Dpackaging=native-image -Pinstrumented
```

2. Run the app and apply relevant workload:

```shell
mv ./target/micronaut-photobook*runner ./target/micronaut-photobook-instrumented
```

```shell
./target/micronaut-photobook-instrumented
```
Expand All @@ -193,7 +189,7 @@ after you shut down the app, you'll see an `iprof` file in your working director
3. Build an app with profiles (they are being picked up via `<buildArg>--pgo=${project.basedir}/default.iprof</buildArg>`):

```shell
mvn package -Dnative -Poptimized
mvn package -Dpackaging=native-image -Poptimized
```

## Benchmark scripts
Expand Down Expand Up @@ -225,21 +221,30 @@ Follow steps in 'Native optimization : PGO' section

### 3. Benchmark result

Here are shown the result of a run on one of my systems (Multiple runs have been recorded with consistent results) :


```
Ubuntu 22.04.4 LTS
AMD Ryzen 7 3700X
32 GB of RAM
```

Sample result of JIT benchmark run :

![JIT Benchmark Result](src/main/docs/images/bench-result-jit-20240617.png)
![JIT Benchmark Result](src/main/docs/images/bench-result-jit-20240619.png)

Sample result of native (AOT) benchmark run :

![Native Benchmark Result](src/main/docs/images/bench-result-native-20240617.png)
![Native Benchmark Result](src/main/docs/images/bench-result-native-20240619.png)

## application stack

| Layer | 2024 version |
|-------------------|----------------|
| Persistence | MongoDB 8 |
| Java version | GraalVM 21 |
| API REST | Quarkus 3.11.x |
| Node JS | Node 20 |
| Front end package | Vite |
| Front end UI | React 18.3 |
| Layer | 2024 version |
|-------------------|-----------------|
| Persistence | MongoDB 8 |
| Java version | GraalVM 21 |
| API REST | Micronaut 4.5.x |
| Node JS | Node 20 |
| Front end package | Vite |
| Front end UI | React 18.3 |
40 changes: 40 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,46 @@
</build>
</profile>

<profile>
<id>instrumented</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<imageName>${project.artifactId}-instrumented</imageName>
<buildArgs>
<buildArg>--pgo-instrument</buildArg>
<buildArg>-H:IncludeResources=build.properties</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>optimized</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<imageName>${project.artifactId}-optimized</imageName>
<buildArgs>
<!--<buildArg>gc=G1</buildArg>-->
<buildArg>--pgo=${project.basedir}/default.iprof</buildArg>
<buildArg>-march=native</buildArg>
<buildArg>-H:IncludeResources=build.properties</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>

</project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/script/bench-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export TEST_URL=http://localhost:8080/photobook-demo/api/photobook/view/images/s
export LOOP_COUNT=250000
export BASE_DIR=./target

${BASE_DIR}/micronaut-photobook -Xmx512m &
${BASE_DIR}/micronaut-photobook-optimized -Xmx512m &
export PID=$!
psrecord $PID --plot "${BASE_DIR}/$(date +%s)-native.png" --include-children &

Expand All @@ -30,6 +30,6 @@ hey -n=${LOOP_COUNT} -c=8 ${TEST_URL}
print "Executing benchmark load"
hey -n=${LOOP_COUNT} -c=8 ${TEST_URL}

print "JVM run done!🎉"
print "native run done!🎉"
kill $PID
sleep 1

0 comments on commit d5db671

Please sign in to comment.