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 throws error when attempting to profile Rust application #293

Open
trevorstr opened this issue Oct 23, 2023 · 6 comments
Open

Comments

@trevorstr
Copy link

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.

@djc
Copy link
Contributor

djc commented Oct 23, 2023

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.

@trevorstr
Copy link
Author

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.

@djc
Copy link
Contributor

djc commented Oct 23, 2023

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

@trevorstr
Copy link
Author

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

@larseggert
Copy link

larseggert commented Feb 26, 2024

I'm having a similar issue. Was wondering whether sudo could be passed the --preserve-env argument with a list that includes DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH, etc.?

@djc
Copy link
Contributor

djc commented Feb 27, 2024

Sounds reasonable to me, want to submit a PR?

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

3 participants