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

Add collapser for sample on macOS #133

Merged
merged 11 commits into from
Jul 6, 2019
Merged

Conversation

jasonrhansen
Copy link
Collaborator

This diverges a bit in behavior from stackcollapse-sample.awk from upstream. For some reason it was implemented in a way that it outputs a bunch of erroneous stacks with 0 samples. This Rust version doesn't do that. However, the resulting flamegraphs should be the same between the two since those lines with 0 samples will be skipped over when generating the flamegraph.

One unfortunate thing about sample is it has the same problem demangling Rust names as DTrace. At least with DTrace there's a way to disable demangling so we can handle it in our collapser. I didn't add demangling to this collapser because, as far as I can tell, there's no way to disable demangling for sample.


fn write_stack<W: Write>(&self, writer: &mut W) -> io::Result<()> {
if let Some(func) = self.stack.last() {
for symbol in IGNORE_SYMBOLS {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How sure are we that everyone will always want to ignore these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure at all. I was just following upstream. Maybe we should add an option for this?

@jonhoo
Copy link
Owner

jonhoo commented Jul 5, 2019

Depending on how the demangling is by default, it could be that it makes sense for us to just do it again?

@jasonrhansen
Copy link
Collaborator Author

For rustc_demangle to properly demangle Rust names, the names need to be mangled. Taking the improperly demangled Rust names from sample and demangling again doesn't work. At least DTrace has an option to leave names mangled, but not sample.

@jasonrhansen
Copy link
Collaborator Author

I don't know why the collapse_sample_cli test times out on Travis CI for Windows. I just tried running the tests on Windows without a problem.

@jonhoo
Copy link
Owner

jonhoo commented Jul 5, 2019

Seems to fail on FreeBSD too? Is it just really slow?

@jasonrhansen
Copy link
Collaborator Author

It's not slow at all when I run it on my computer. The whole test suite runs in 4 or 5 seconds.

@jonhoo
Copy link
Owner

jonhoo commented Jul 5, 2019

Hmm, that's very interesting. It seems to run just fine on my box too. The test does use assert-cmd, and I came across assert-rs/assert_cmd#42, which indicates that there's deadlock potential if stdin/stdout is particularly large, which may be the case for this test?

@jasonrhansen
Copy link
Collaborator Author

The input is 125k, but the input file we use for dtrace is 1.4M and that one doesn't deadlock.

@jonhoo
Copy link
Owner

jonhoo commented Jul 5, 2019

I'll try restarting it and see if that helps. If not, maybe try adding

-- --test-threads=1 --nocapture

and some basic println! statements to that test so we can at least see where the test hangs?

@jonhoo
Copy link
Owner

jonhoo commented Jul 5, 2019

@jasonrhansen hmm, nope, looks like it got stuck on the exact same test again :/

@jasonrhansen
Copy link
Collaborator Author

I haven't yet figured out why the tests are timing out on CI, but I came up with a solution to the poorly demangled Rust symbols. Using rustc_demangle on these doesn't work, but I took relevant parts of it and wrote a function that fixes these "partially demangled" Rust names. This could be used in the dtrace collapser as well, which would be much nicer than having to run dtrace with -xmangled and inferno-collapse-dtrace with --demangle.

@jasonrhansen
Copy link
Collaborator Author

I couldn't figure out how to get that test to work so I just disabled it for now.

@codecov
Copy link

codecov bot commented Jul 6, 2019

Codecov Report

Merging #133 into master will decrease coverage by 0.19%.
The diff coverage is 88.41%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #133     +/-   ##
=========================================
- Coverage   89.72%   89.52%   -0.2%     
=========================================
  Files           8       10      +2     
  Lines         983     1146    +163     
=========================================
+ Hits          882     1026    +144     
- Misses        101      120     +19
Impacted Files Coverage Δ
src/collapse/mod.rs 54.54% <ø> (ø) ⬆️
src/collapse/perf.rs 92.15% <100%> (+0.07%) ⬆️
src/collapse/guess.rs 71.42% <66.66%> (-1.65%) ⬇️
src/collapse/sample.rs 87.62% <87.62%> (ø)
src/collapse/util/mod.rs 90.32% <90.32%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eae7aa3...39712a4. Read the comment docs.

@jonhoo jonhoo merged commit 07b69a1 into jonhoo:master Jul 6, 2019
@jonhoo
Copy link
Owner

jonhoo commented Jul 6, 2019

Excellent! Thank you 🎉

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

Successfully merging this pull request may close these issues.

2 participants