From 9f47201babdda576378d3075ad5bc6f4b0824c66 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 13 Feb 2025 17:02:58 +0100 Subject: [PATCH] bench: add a `profiling` profile that doesn't enable LTO for quick rebuilds --- Cargo.toml | 7 +++++++ benchmarks/README.md | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 165cc836a..27bc4be74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -143,6 +143,13 @@ debug = 2 inherits = "dbg" opt-level = 3 +[profile.profiling] +inherits = "release" +# LTO is too slow to compile. +lto = false +# Get symbol names for profiling purposes. +debug = true + [patch.crates-io] async-compat = { git = "https://github.com/jplatte/async-compat", rev = "16dc8597ec09a6102d58d4e7b67714a35dd0ecb8" } const_panic = { git = "https://github.com/jplatte/const_panic", rev = "9024a4cb3eac45c1d2d980f17aaee287b17be498" } diff --git a/benchmarks/README.md b/benchmarks/README.md index ce09dd943..458497bb4 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -8,7 +8,7 @@ can be found [here](https://bheisler.github.io/criterion.rs/book/criterion_rs.ht ## Running the benchmarks -The benchmark can be simply run by using the `bench` command of `cargo`: +The benchmark can be run by using the `bench` command of `cargo`: ```bash $ cargo bench @@ -16,6 +16,13 @@ $ cargo bench This will work from the workspace directory of the rust-sdk. +To lower compile times, you might be interested in using the `profiling` profile, that's optimized +for a fair tradeoff between compile times and runtime performance: + +```bash +$ cargo bench --profile profiling +``` + If you want to pass options to the benchmark [you'll need to specify the name of the benchmark](https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options): @@ -23,7 +30,7 @@ the benchmark](https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench $ cargo bench --bench crypto_bench -- # Your options go here ``` -If you want to run only a specific benchmark, simply pass the name of the +If you want to run only a specific benchmark, pass the name of the benchmark as an argument: ```bash @@ -65,7 +72,7 @@ permisive value is `-1`: $ echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid ``` -To generate flame graphs feature simply enable the profiling mode using the +To generate flame graphs feature, enable the profiling mode using the `--profile-time` command line flag: ```bash