-
Notifications
You must be signed in to change notification settings - Fork 125
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
Trim executable name when getting function color #329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small nit! I'm okay landing it for just Rust if we're not sure whether you end up with the same kinds of trace lines for other languages. If on the other hand you have evidence that the exact same thing applies to other languages, I think it's worthwhile changing for all of them!
src/flamegraph/color/palettes.rs
Outdated
let name = if let Some(i) = name.find('`') { | ||
&name[i + 1..] | ||
} else { | ||
name | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use split_once
to great effect here:
let name = if let Some(i) = name.find('`') { | |
&name[i + 1..] | |
} else { | |
name | |
}; | |
let name = name.split_once('`').map(|(_, after)| after).unwrap_or(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, done in c41a5ba
It looks like Java and Python are profiled differently (using AsyncProfiler and austin respectively?), so I'm going to leave this as Rust-exclusive for now. |
c41a5ba
to
882e344
Compare
On illumos, the DTrace script prints the library or executable before the function in the stack trace, e.g.
This means that tests like
name.starts_with("core::")
don't work.This PR updates the Rust color selector to drop anything before the backtick, so that calls to
starts_with(..)
correctly classify functions incore
/std
/ etc.I only did it for Rust because that's what I'm using; if you want, I can make the equivalent change for Java and Python resolvers (which also use
starts_with
).Thanks!