pprof use only linux
pprof use only linux
MODIFY
benchmarks/Cargo.toml
benchmarks/Cargo.toml
@@ -34,6 +34,7 @@ starcoin-network-api = {path = "../network/api", package="network-api"}
executor-benchmark = {path = "../executor/benchmark", package="starcoin-executor-benchmark" }
futures = "0.3.12"
logger = {path = "../commons/logger",package="starcoin-logger"}
+[target."cfg(target_os=\"linux\")".dependencies]
pprof = { version = "0.4", features = ["flamegraph", "criterion"] }
[dev-dependencies]

MODIFY
benchmarks/README.md
benchmarks/README.md
@@ -12,7 +12,7 @@ cargo bench
cargo bench --bench bench_state_tree
```
-3. run a special benchmark with pprof
+3. run a special benchmark with pprof (on linux)
```shell
cargo bench --bench bench_state_tree -- --profile-time=10
```

MODIFY
benchmarks/benches/bench_chain.rs
benchmarks/benches/bench_chain.rs
use benchmarks::chain::ChainBencher;
#[allow(deprecated)]
use criterion::{criterion_group, criterion_main, Benchmark, Criterion};
+#[cfg(target_os = "linux")]
use pprof::criterion::{Output, PProfProfiler};
#[allow(deprecated)]
@@ -38,10 +39,12 @@ fn query_block(c: &mut Criterion) {
}
}
}
-
+#[cfg(target_os = "linux")]
criterion_group!(
name=starcoin_chain_benches;
config = Criterion::default()
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets=block_apply,query_block);
+#[cfg(not(target_os = "linux"))]
+criterion_group!(starcoin_chain_benches, block_apply, query_block);
criterion_main!(starcoin_chain_benches);

MODIFY
benchmarks/benches/bench_state_tree.rs
benchmarks/benches/bench_state_tree.rs
@@ -5,6 +5,7 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use crypto::hash::*;
use forkable_jellyfish_merkle::blob::Blob;
use forkable_jellyfish_merkle::HashValueKey;
+#[cfg(target_os = "linux")]
use pprof::criterion::{Output, PProfProfiler};
use rand::{rngs::StdRng, SeedableRng};
use starcoin_config::RocksdbConfig;
@@ -98,12 +99,14 @@ fn bench_put_and_commit(c: &mut Criterion) {
group.finish();
}
-
+#[cfg(target_os = "linux")]
criterion_group!(
name=benches;
config = Criterion::default()
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets=bench_get_with_proof, bench_put_and_commit);
+#[cfg(not(target_os = "linux"))]
+criterion_group!(benches, bench_get_with_proof, bench_put_and_commit);
criterion_main!(benches);
fn gen_kv_from_seed(seed: &[u8], num_keys: usize) -> HashMap<HashValueKey, Blob> {

MODIFY
benchmarks/benches/bench_storage.rs
benchmarks/benches/bench_storage.rs
use benchmarks::storage::StorageBencher;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use crypto::HashValue;
+#[cfg(target_os = "linux")]
use pprof::criterion::{Output, PProfProfiler};
use starcoin_accumulator::{accumulator_info::AccumulatorInfo, Accumulator, MerkleAccumulator};
use starcoin_config::RocksdbConfig;
@@ -62,10 +63,17 @@ fn create_leaves(nums: std::ops::Range<usize>) -> Vec<HashValue> {
nums.map(|x| HashValue::sha3_256_of(x.to_be_bytes().as_ref()))
.collect()
}
+#[cfg(target_os = "linux")]
criterion_group!(
name=starcoin_storage_benches;
config = Criterion::default()
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets=storage_transaction, accumulator_append
);
+#[cfg(not(target_os = "linux"))]
+criterion_group!(
+ starcoin_storage_benches,
+ storage_transaction,
+ accumulator_append
+);
criterion_main!(starcoin_storage_benches);

MODIFY
benchmarks/benches/bench_vm.rs
benchmarks/benches/bench_vm.rs
// SPDX-License-Identifier: Apache-2.0
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use executor_benchmark::run_benchmark;
+#[cfg(target_os = "linux")]
use pprof::criterion::{Output, PProfProfiler};
pub fn transaction_execution(c: &mut Criterion) {
@@ -16,9 +17,12 @@ pub fn transaction_execution(c: &mut Criterion) {
}
}
+#[cfg(target_os = "linux")]
criterion_group!(
name=starcoin_vm_benches;
config = Criterion::default()
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets=transaction_execution);
+#[cfg(not(target_os = "linux"))]
+criterion_group!(starcoin_vm_benches, transaction_execution);
criterion_main!(starcoin_vm_benches);

pprof use only linux (#3004)

pprof use only linux