From 56a30b3a023eb005b7ca305a0d4cb2d45d42ed68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 9 Sep 2021 13:35:43 +0200 Subject: [PATCH] chore(crypto): Bump the pprof version and remove our custom profiler --- matrix_sdk_crypto/Cargo.toml | 2 +- matrix_sdk_crypto/benches/crypto_bench.rs | 8 +-- matrix_sdk_crypto/benches/perf.rs | 76 ----------------------- 3 files changed, 5 insertions(+), 81 deletions(-) delete mode 100644 matrix_sdk_crypto/benches/perf.rs diff --git a/matrix_sdk_crypto/Cargo.toml b/matrix_sdk_crypto/Cargo.toml index 587e420e..b32074cb 100644 --- a/matrix_sdk_crypto/Cargo.toml +++ b/matrix_sdk_crypto/Cargo.toml @@ -57,7 +57,7 @@ indoc = "1.0.3" criterion = { version = "0.3.4", features = ["async", "async_tokio", "html_reports"] } [target.'cfg(target_os = "linux")'.dev-dependencies] -pprof = { version = "0.4.3", features = ["flamegraph"] } +pprof = { version = "0.5.0", features = ["flamegraph", "criterion"] } [[bench]] name = "crypto_bench" diff --git a/matrix_sdk_crypto/benches/crypto_bench.rs b/matrix_sdk_crypto/benches/crypto_bench.rs index 280d01af..d919b9db 100644 --- a/matrix_sdk_crypto/benches/crypto_bench.rs +++ b/matrix_sdk_crypto/benches/crypto_bench.rs @@ -1,6 +1,3 @@ -#[cfg(target_os = "linux")] -mod perf; - use std::sync::Arc; use criterion::*; @@ -262,7 +259,10 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) { fn criterion() -> Criterion { #[cfg(target_os = "linux")] - let criterion = Criterion::default().with_profiler(perf::FlamegraphProfiler::new(100)); + let criterion = Criterion::default().with_profiler(pprof::criterion::PProfProfiler::new( + 100, + pprof::criterion::Output::Flamegraph(None), + )); #[cfg(not(target_os = "linux"))] let criterion = Criterion::default(); diff --git a/matrix_sdk_crypto/benches/perf.rs b/matrix_sdk_crypto/benches/perf.rs deleted file mode 100644 index b2dfb878..00000000 --- a/matrix_sdk_crypto/benches/perf.rs +++ /dev/null @@ -1,76 +0,0 @@ -//! This is a simple Criterion Profiler implementation using pprof. -//! -//! It's mostly a direct copy from here: https://www.jibbow.com/posts/criterion-flamegraphs/ -use std::{fs::File, os::raw::c_int, path::Path}; - -use criterion::profiler::Profiler; -use pprof::ProfilerGuard; - -/// Small custom profiler that can be used with Criterion to create a flamegraph -/// for benchmarks. Also see [the Criterion documentation on -/// this][custom-profiler]. -/// -/// ## Example on how to enable the custom profiler: -/// -/// ``` -/// mod perf; -/// use perf::FlamegraphProfiler; -/// -/// fn fibonacci_profiled(criterion: &mut Criterion) { -/// // Use the criterion struct as normal here. -/// } -/// -/// fn custom() -> Criterion { -/// Criterion::default().with_profiler(FlamegraphProfiler::new()) -/// } -/// -/// criterion_group! { -/// name = benches; -/// config = custom(); -/// targets = fibonacci_profiled -/// } -/// ``` -/// -/// The neat thing about this is that it will sample _only_ the benchmark, and -/// not other stuff like the setup process. -/// -/// Further, it will only kick in if `--profile-time