junyu-w / genson-rs

Blazing-fast JSON Schema inference engine built in Rust
Apache License 2.0
69 stars 1 forks source link

Evaluate Profile-Guided Optimization (PGO) usage #1

Open zamazan4ik opened 3 months ago

zamazan4ik commented 3 months ago

Hi!

Since the README file mentions a lot of performance-oriented things, I decided to test one compiler optimization - Profile-Guided Optimization (PGO) on genson-rs. I already tested it on various projects with positive results (you can find all benchmarks here: https://github.com/zamazan4ik/awesome-pgo), so here are the benchmark results for genson-rs.

Test environment

Benchmark

For benchmark purposes, I use built-in into the project benchmarks. For PGO optimization I use cargo-pgo tool. Release bench result I got with the taskset -c 0 cargo bench command. The PGO training phase is done with taskset -c 0 cargo pgo bench, PGO optimization phase - with taskset -c 0 cargo pgo optimize bench.

All measurements are done on the same machine, with the same background "noise" (as much as I can guarantee). taskset -c 0 is used for reducing OS scheduler "noise".

Results

I got the following results:

According to the results, PGO measurably improves the tool's performance at least in the benchmark above.

Further steps

I can suggest the following action points:

Testing Post-Link Optimization techniques (like LLVM BOLT) would be interesting too (Clang and Rustc already use BOLT as an addition to PGO) but I recommend starting from the usual PGO.

I would be happy to answer your questions about PGO.

P.S. I created the Issue since Discussions are disabled for the repo. Since it's not the issue but an improvement idea, probably Discussions is a better place to discuss such things.

junyu-w commented 3 months ago

This is great idea! I will test it out