@@ -102,28 +102,28 @@ Expected output:
102102``` sh
103103sudo apt install linux-tools-common linux-tools-generic gcc zlib1g-dev
104104sudo 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
106106ls -l ./example01_graalvm.bin
107107perf stat -r 100 ./example01_graalvm.bin > /dev/null
108108```
109109Expected output:
110110``` text
111111 Performance counter stats for './example01_graalvm.bin' (100 runs):
112112
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 % )
115115 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 % )
125125
126- 0.00196304 +- 0.00000988 seconds time elapsed ( +- 0.50 % )
126+ 0.0016622 +- 0.0000371 seconds time elapsed ( +- 2.23 % )
127127```
128128
129129### Build Scala Native image, print its size, and measure its start up time
@@ -201,7 +201,7 @@ sys 0m4.102s
201201### Build GraalVM native image, print its size, and measure its running time
202202
203203``` 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
205205ls -l ./example02_graalvm.bin
206206time ./example02_graalvm.bin < 2023_06_430_65B0_in_network_rates.json 2> /dev/null
207207```
@@ -215,7 +215,7 @@ sys 0m5.151s
215215You can use profile guided optimization (PGO) to improve performance of Oracle GraalVM native image, for that you need:
216216- build an instrumented GraalVM native image with ` --pgo-instrument ` option added:
217217``` 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
219219ls -l ./example02_graalvm_instrumented.bin
220220```
221221- 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
224224```
225225- build a PGO-optimized GraalVM native image with ` --pgo=default.iprof ` option added:
226226``` 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
228228ls -l ./example02_graalvm_optimized.bin
229229```
230230- run the PGO-optimized image:
0 commit comments