Skip to content

Flamegraph doesn't seem to display user-defined functions #341

@jpmedinagl

Description

@jpmedinagl

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

I tried running it on my project and I obtain this graph. The code is over 1k lines of code and have many different function calls so I don't know why no functions would show up

This is what I run, I increased the frequency but it doesn't seem to do much.

$ cargo flamegraph --freq 2000 --bin basic

image

I tried creating a random test file to see if I could get a flamegraph non-related to my project. And the flamegraph still doesn't really show the function names. It was suggested on a rust discord to try and use std::hint::black_box to block optimizations and it still doesn't really seem to work.

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

Is there some setting I'm missing? Right now I want to have a test file that produces a flamegraph with user def functions because I can't seem to do that so unrelated to my project I can't get flamegraph to work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions