Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flamegraph not displaying user-defined functions #347

Open
jpmedinagl opened this issue Oct 30, 2024 · 0 comments
Open

Flamegraph not displaying user-defined functions #347

jpmedinagl opened this issue Oct 30, 2024 · 0 comments

Comments

@jpmedinagl
Copy link

I'm working on a project using flamegraph and for some reason I can't get Flamegraph to display user-defined functions. These are my configs

[dependencies]
libc = "0.2.155"
faer = "0.19.0"
flamegraph = "=0.5.0"

[profile.dev]
debug = true
opt-level = 0
debug-assertions = true
strip = false

[profile.release]
debug = true
strip = false

This is what I use to create the flamegraphs (in my base Cargo.toml, I cloned Flamegraph so I could access stackcollapse-perf.pl and flamegraph.pl)

$ perf record -g ./target/release/basic
$ perf script > out.perf
$ ./Flamegraph/stackcollapse-perf.pl out.perf > out.txt
$ ./Flamegraph/flamegraph.pl out.txt > flame.svg

My project is over 1k lines of code so I'm not sure why user-defined functions aren't showing up

image

I also tried writing a random test file with a loop to try and see if I could get it working aside from the project. I also tried using blackbox to try and block out optimization.

use std::hint::black_box;

#[no_mangle]
pub fn sum() -> i32 {
    let mut sum = 0;
    for i in 0..1000 {
        sum += std::hint::black_box(1);
    }
    return sum;
}

fn main() {
    println!("Sum: {}", black_box(sum()));
}

image

I also checked and the file has debug info and is not stripped

$ file ./target/release/basic
./target/release/basic: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=e36e552eded3fad47af12fd3b0ab9049b0f0a524, for GNU/Linux 3.2.0, with debug_info, not stripped

I also tried running with dwarf which just produced a different flamegraph

$ perf record --call-graph dwarf ./target/debug/basic
$ perf script > out.perf
$ ./Flamegraph/stackcollapse-perf.pl out.perf > out.txt
$ ./Flamegraph/flamegraph.pl out.txt > flame.svg

image

I'm not really sure if I'm just missing a setting or something. But I can't seem to get flamegraph to display any user-defined functions. Is there something I'm not considering?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant