@@ -102,28 +102,28 @@ Expected output:
102
102
``` sh
103
103
sudo apt install linux-tools-common linux-tools-generic gcc zlib1g-dev
104
104
sudo sysctl kernel.perf_event_paranoid=1
105
- scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example01.sc --force -o example01_graalvm.bin -- --no-fallback -march=native
105
+ scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example01.sc --force -o example01_graalvm.bin -- --no-fallback -O3 -H:+UnlockExperimentalVMOptions -R:MaxHeapSize=16m -H:-GenLoopSafepoints -H:-ParseRuntimeOptions -H:-IncludeMethodData --initialize-at-build-time
106
106
ls -l ./example01_graalvm.bin
107
107
perf stat -r 100 ./example01_graalvm.bin > /dev/null
108
108
```
109
109
Expected output:
110
110
``` text
111
111
Performance counter stats for './example01_graalvm.bin' (100 runs):
112
112
113
- 1.84 msec task-clock # 0.939 CPUs utilized ( +- 0.40 % )
114
- 1 context-switches # 542.721 /sec ( +- 3.21 % )
113
+ 1.54 msec task-clock # 0.929 CPUs utilized ( +- 2.17 % )
114
+ 1 context-switches # 647.939 /sec ( +- 2.93 % )
115
115
0 cpu-migrations # 0.000 /sec
116
- 633 page-faults # 343.543 K/sec ( +- 0.01% )
117
- 7,594,064 cycles # 4.121 GHz ( +- 0.49 % )
118
- 11,150,492 instructions # 1.47 insn per cycle ( +- 0.04% )
119
- 2,133,178 branches # 1.158 G/sec ( +- 0.03% )
120
- 21,759 branch-misses # 1.02 % of all branches ( +- 0.84 % )
121
- TopdownL1 # 32.0 % tma_backend_bound
122
- # 6.5 % tma_bad_speculation
123
- # 30.0 % tma_frontend_bound
124
- # 31.5 % tma_retiring ( +- 0.49 % )
116
+ 535 page-faults # 346.647 K/sec ( +- 0.01% )
117
+ 6,194,402 cycles # 4.014 GHz ( +- 0.32 % )
118
+ 8,776,339 instructions # 1.42 insn per cycle ( +- 0.04% )
119
+ 1,661,644 branches # 1.077 G/sec ( +- 0.03% )
120
+ 18,496 branch-misses # 1.11 % of all branches ( +- 0.87 % )
121
+ TopdownL1 # 32.3 % tma_backend_bound
122
+ # 6.6 % tma_bad_speculation
123
+ # 30.4 % tma_frontend_bound
124
+ # 30.7 % tma_retiring ( +- 0.31 % )
125
125
126
- 0.00196304 +- 0.00000988 seconds time elapsed ( +- 0.50 % )
126
+ 0.0016622 +- 0.0000371 seconds time elapsed ( +- 2.23 % )
127
127
```
128
128
129
129
### Build Scala Native image, print its size, and measure its start up time
@@ -201,7 +201,7 @@ sys 0m4.102s
201
201
### Build GraalVM native image, print its size, and measure its running time
202
202
203
203
``` sh
204
- scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example02.sc --force -o example02_graalvm.bin -- --no-fallback --gc=epsilon -O3
204
+ scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example02.sc --force -o example02_graalvm.bin -- --no-fallback --gc=epsilon -O3 -H:+UnlockExperimentalVMOptions -R:MaxHeapSize=16m -H:-GenLoopSafepoints -H:-ParseRuntimeOptions -H:-IncludeMethodData --initialize-at-build-time
205
205
ls -l ./example02_graalvm.bin
206
206
time ./example02_graalvm.bin < 2023_06_430_65B0_in_network_rates.json 2> /dev/null
207
207
```
@@ -215,7 +215,7 @@ sys 0m5.151s
215
215
You can use profile guided optimization (PGO) to improve performance of Oracle GraalVM native image, for that you need:
216
216
- build an instrumented GraalVM native image with ` --pgo-instrument ` option added:
217
217
``` sh
218
- scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example02.sc --force -o example02_graalvm_instrumented.bin -- --no-fallback --gc=epsilon -O3 --pgo-instrument
218
+ scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example02.sc --force -o example02_graalvm_instrumented.bin -- --no-fallback --gc=epsilon -O3 --pgo-instrument -H:+UnlockExperimentalVMOptions -R:MaxHeapSize=16m -H:-GenLoopSafepoints -H:-ParseRuntimeOptions -H:-IncludeMethodData --initialize-at-build-time
219
219
ls -l ./example02_graalvm_instrumented.bin
220
220
```
221
221
- run the instrumented image and collect the profile data:
@@ -224,7 +224,7 @@ time ./example02_graalvm_instrumented.bin < 2023_06_430_65B0_in_network_rates.js
224
224
```
225
225
- build a PGO-optimized GraalVM native image with ` --pgo=default.iprof ` option added:
226
226
``` sh
227
- scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example02.sc --force -o example02_graalvm_optimized.bin -- --no-fallback --gc=epsilon -O3 --pgo=default.iprof
227
+ scala-cli --power package --graalvm-jvm-id graalvm-oracle:23 --native-image example02.sc --force -o example02_graalvm_optimized.bin -- --no-fallback --gc=epsilon -O3 --pgo=default.iprof -H:+UnlockExperimentalVMOptions -R:MaxHeapSize=16m -H:-GenLoopSafepoints -H:-ParseRuntimeOptions -H:-IncludeMethodData --initialize-at-build-time
228
228
ls -l ./example02_graalvm_optimized.bin
229
229
```
230
230
- run the PGO-optimized image:
0 commit comments