flamegraph-rs / flamegraph

Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flamegraph throws error when attempting to profile Rust application

trevorstr opened this issue · comments

commented

Summary

I'm using CoreML with the ONNX runtime (ort crate) to run inference against a machine learning model.

I want to use flamegraph to find out where performance limitations might be occurring. My objective is to optimize my program for speed, and remove any unnecessary code.

After installing flamegraph, I tried running it and immediately received an error.
This error is blocking me from making any progress with flamegraph.

I also tried samply, but received a similar result.
Hence, I don't believe this problem is necessarily specific to only flamegraph.

Actual Result

When I run flamegraph against my program, I get the following error:

> sudo flamegraph --output flamegraph.svg -- ./zzzzzzz/target/debug/zzzzzzz
dtrace: system integrity protection is on, some features will not be available

dyld[32990]: Library not loaded: @rpath/libonnxruntime.1.16.0.dylib
  Referenced from: <79BEC317-46CD-3AA4-9049-486577A7884B> /Users/trevor.sullivan/git/zzzzzzz/target/debug/zzzzzzz
  Reason: no LC_RPATH's found
dtrace: failed to control pid 32990: process exited with status 0
failed to sample program

Expected Result

I expected flamegraph to profile my code and generate an SVG file.

I'm guessing dynamic linking fails because the libonnxruntime library isn't available while running in a sudo environment.

I'm assuming you're on macOS, I'd recommend trying samply instead of flamegraph since the dtrace backend on macOS has generally not been that great.

commented

I'm guessing dynamic linking fails because the libonnxruntime library isn't available while running in a sudo environment.

I'm assuming you're on macOS, I'd recommend trying samply instead of flamegraph since the dtrace backend on macOS has generally not been that great.

Actually, I had mentioned in my original post that I already tried samply as well. 🙂 I received a similar result with both profilers.

Ah, sorry -- missed that. Anyway, my other point stands, and might apply to samply as well if you're using sudo to run it?

commented

I tried running flamegraph on another application, which does not use the ort crate. Instead, it relies on tokio and the aws-config crate. Flamegraph worked just fine, when invoked on that binary, using sudo.

I have to run flamegraph with sudo, otherwise I get a permissions issue from dtrace.

dtrace: system integrity protection is on, some features will not be available
dtrace: failed to initialize dtrace: DTrace requires additional privileges
failed to sample program

Seems like the issue is specific to ONNX.

Screenshot 2023-10-23 at 10 27 31 AM