Skip to content

Commit

Permalink
fix: enable profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Jul 21, 2023
1 parent c371e74 commit f99b073
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions components/hord-cli/Cargo.toml
Expand Up @@ -38,7 +38,7 @@ fxhash = "0.2.1"
rusqlite = { version = "0.27.0", features = ["bundled"] }
anyhow = { version = "1.0.56", features = ["backtrace"] }
schemars = { version = "0.8.10", git = "https://github.com/hirosystems/schemars.git", branch = "feat-chainhook-fixes" }
pprof = { version = "0.12", features = ["flamegraph"], optional = true }
pprof = { version = "0.12", features = ["flamegraph"] }
progressing = '3'

[dependencies.rocksdb]
Expand All @@ -49,5 +49,5 @@ features = ["lz4", "snappy"]
[features]
default = ["cli"]
cli = ["clap", "clap_generate", "toml", "ctrlc", "hiro-system-kit/log"]
debug = ["hiro-system-kit/debug", "pprof"]
debug = ["hiro-system-kit/debug"]
release = ["hiro-system-kit/release"]
40 changes: 20 additions & 20 deletions components/hord-cli/src/db/mod.rs
Expand Up @@ -1856,11 +1856,11 @@ pub async fn rebuild_rocks_db(
hord_config: &HordConfig,
ctx: &Context,
) -> Result<(), String> {
// let guard = pprof::ProfilerGuardBuilder::default()
// .frequency(20)
// .blocklist(&["libc", "libgcc", "pthread", "vdso"])
// .build()
// .unwrap();
let guard = pprof::ProfilerGuardBuilder::default()
.frequency(20)
.blocklist(&["libc", "libgcc", "pthread", "vdso"])
.build()
.unwrap();

ctx.try_log(|logger| {
slog::info!(logger, "Generating report");
Expand Down Expand Up @@ -1982,21 +1982,21 @@ pub async fn rebuild_rocks_db(
)
});

// match guard.report().build() {
// Ok(report) => {
// ctx.try_log(|logger| {
// slog::info!(logger, "Generating report");
// });

// let file = File::create("hord-perf.svg").unwrap();
// report.flamegraph(file).unwrap();
// }
// Err(e) => {
// ctx.try_log(|logger| {
// slog::error!(logger, "Reporting failed: {}", e.to_string());
// });
// }
// }
match guard.report().build() {
Ok(report) => {
ctx.try_log(|logger| {
slog::info!(logger, "Generating report");
});

let file = std::fs::File::create("hord-perf.svg").unwrap();
report.flamegraph(file).unwrap();
}
Err(e) => {
ctx.try_log(|logger| {
slog::error!(logger, "Reporting failed: {}", e.to_string());
});
}
}
return Ok(());
}

Expand Down

0 comments on commit f99b073

Please sign in to comment.