fix: enable profiling

This commit is contained in:
Ludo Galabru
2023-07-21 14:24:15 -04:00
parent c371e74de7
commit f99b073528
2 changed files with 21 additions and 21 deletions

View File

@@ -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]
@@ -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"]

View File

@@ -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");
@@ -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");
// });
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());
// });
// }
// }
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(());
}