flamegraph-rs / flamegraph

Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3
Apache License 2.0
4.75k stars 145 forks source link

SVG report doesn't contain my Rust functions #330

Open nricciardi opened 4 months ago

nricciardi commented 4 months ago

I'm using Flamegraph on Linux Mint 21.3 (kernel 5.15.0-113-generic) to profile my Rust application. When I run

cargo flamegraph -- [my args]

the terminal remains blocked showing:

[ perf record: Woken up 82 times to write data ]
[ perf record: Captured and wrote 22,570 MB perf.data (1421 samples) ]

(SVG file is not produced)

I must interrupt with CTRL + C and then SVG report is produced, but it does not have any profiled function of my Rust application.

If I run flamegraph with the same application, but throwing e.g. todo!(), then terminal exits correctly and flamegraph produces SVG report without CTRL + C.

My Cargo.toml file is the following:

[dependencies]
anyhow = "1.0.75"
base64 = "0.21.5"
build_html = "2.4.0"
clap = "4.4.18"
env_logger = "0.10.1"
image = "0.24.8"
log = "0.4.20"
notify = "6.1.1"
oxipng = { version = "9.1.1", features = ["parallel"]}
rayon = "1.8.0"
regex = "1.10.2"
reqwest = { version = "0.11.24", features = ["blocking"] }
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.113"
serde_yaml = "0.9.31"
simple_logger = "4.3.3"
thiserror = "1.0.50"
url = "2.5.0"

[profile.release]
debug = true

I have tried also using --root option without results. How can I fix it?

djc commented 4 months ago

I don't think there is enough information here for me to diagnose this, and it seems unlikely to be a problem with cargo flamegraph itself. I'm guessing your application hangs. Maybe you can try perf record to record a profile and then process it with flamegraph? Or maybe try the samply profiler instead.

nricciardi commented 4 months ago

Thank you to answer me.

How can I produce SVG using flamegraph from perf record output?

However, to reproduce my issue, my Rust application is a Markdown compiler (https://github.com/nricciardi/nmd). Running, for example, cargo flamegraph -- compile dossier -i test-resources/nmd-test-dossier-1 --fast-draft

Using a simple main having only one instruction std::process::exit(0); profiling terminates correctly producing SVG. In particular, after [perf record: ...] there is a new line: writing flamegraph to "flamegraph.svg"

I tried to put exit(0) in my code without any results, but sometimes (in a no deterministic way) writing flamegraph to "flamegraph.svg" was displayed.

djc commented 4 months ago

Sorry, I don't have time to provide support for flamegraph at this level.