Evaluate using Profile-Guided Optimization (PGO) #1849
zamazan4ik
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I decided to test the Profile-Guided Optimization (PGO) technique to optimize the Cairo VM performance. For reference, results for other projects are available at https://github.com/zamazan4ik/awesome-pgo . Since PGO helped a lot for many projects (including compilers and interpreters like GCC, LLVM-based compilers, CPython, etc.), I decided to apply it to this VM to see if the performance win (or loss) can be achieved. Here are my benchmark results.
Test environment
cairo-vm
version:main
branch on commit3fb0344ce038b3a68cae897c403d1f561cfe8da7
Benchmark
For benchmark purposes, I use this benchmark scenario -
cairo-vm-cli $tests_path/$file.json --proof_mode --memory_file /dev/null --trace_file /dev/null --layout starknet_with_keccak
. Benchmark programs are taken from here and compiled into the.json
files withcairo-compile
command (setted up according to the README file):cairo-compile cairo_programs/benchmarks/program_name.cairo --output cairo_programs/benchmarks/program_name.json --proof_mode
. For PGO optimization I use cargo-pgo tool.Commands for building binaries:
cargo build --release --bin cairo-vm-cli
cargo pgo build -- --release --bin cairo-vm-cli
cargo pgo optimize build -- --release --bin cairo-vm-cli
For PGO training I used two programs:
big_factorial.cairo
andbig_fibonacci.cairo
.taskset -c 0
is used to reduce the OS scheduler's influence on the results. All measurements are done on the same machine, with the same background "noise" (as much as I can guarantee). Measurements are done withhyperfine
.Results
I got the following results:
, where
cairo-vm-cli-release
- Release build,cairo-vm-cli-optimized
- PGO-optimized build.According to the results, we see ~15% improvement in performance. The test script was a part of the training dataset. What about other scripts that were not presented in the PGO training dataset? Here we go:
The results at least in this test are the same - +15% performance improvement for
cairo-vm
. Quite a good result.Further steps
I can suggest the following action points:
Also, Post-Link Optimization (PLO) can be tested after PGO. It can be done by applying tools like LLVM BOLT (also supported in the
cargo-pgo
tool). However, it's a much less mature optimization technique compared to PGO.Thank you.
Beta Was this translation helpful? Give feedback.
All reactions