michaelsproul / rust_radix_trie

Fast generic radix trie implemented in Rust
https://docs.rs/radix_trie/
MIT License
184 stars 32 forks source link

Profile-Guided Optimization (PGO) benchmark report #75

Open zamazan4ik opened 3 weeks ago

zamazan4ik commented 3 weeks ago

Hi!

As I have done many times before, I decided to test the Profile-Guided Optimization (PGO) technique to optimize the library performance. For reference, results for other projects are available at https://github.com/zamazan4ik/awesome-pgo . Since PGO helped a lot for many other libraries, I decided to apply it on rust_radix_trie to see if the performance win (or lose) can be achieved. Here are my benchmark results. For benchmarks, I used these benchmarks since this benchmark covers multiple trie libraries: this one and trie-hard from Cloudflare.

This information can be interesting for anyone who wants to achieve more performance with the library in their use cases.

Test environment

Benchmark

For benchmark purposes, I use built-in into the trie-hard project benchmarks. For PGO optimization I use cargo-pgo tool. Release bench results I got with 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.

taskset -c 0 is used for reducing 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).

Results

I got the following results:

According to the results, PGO measurably improves the libraries' performance in most cases.

Further steps

I understand that the steps above can be time-consuming and hard to implement in practice. At the very least, the library's users can find this performance report and decide to enable PGO for their applications if they care about wildcard performance in their workloads. Maybe a small note somewhere in the documentation (the README file?) will be enough to raise awareness about this work.

Please don't treat the issue like an actual issue - it's just a benchmark report (since Discussions are disabled for the repo). I posted the trie-hard results here too since in the trie-hard repository Issues and Discussions are disabled.

Thank you.