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

Upstream flamegraph doesn't discard fractional samples #43

Closed
zao opened this issue Feb 9, 2019 · 6 comments
Closed

Upstream flamegraph doesn't discard fractional samples #43

zao opened this issue Feb 9, 2019 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@zao
Copy link

zao commented Feb 9, 2019

I'm still watching part 2 but given the current state of the source code, I believe that you may have misinterpreted the part of the regex in upstream FlameGraph about removing the fractional part of the samples.

my($stack, $samples) = (/^(.*)\s+?(\d+(?:\.\d*)?)$/);

// strip fractional part (if any);
// foobar 1.klwdjlakdj
if let Some(doti) = samples.find('.') {
samples = &samples[..doti];
}

My reading is that the non-capturing group is there to allow input in either integer or fractional format, but not in any way remove it from the surrounding capture. The non-capturing group is there to group up the separator and the fractions for the following ?.

That is, it accepts sample values like 12, 34., and 56.78.

@jonhoo
Copy link
Owner

jonhoo commented Feb 9, 2019

Ah, yes, I think you're right! That would mean that the sample counts are all fractional (probably f64). Would you be willing to write up a PR with that change?

@zao
Copy link
Author

zao commented Feb 9, 2019

I don't think I've got the mental bandwidth currently to fully implement this as it propagates throughout the program when you make the samples floating point.

In particular, it affects the lookups of TimedFrame due to f64 not having an ordering for Eq nor having a Hash.

I'd gladly leave it for another contributor or for a stream where you get to explain the Fun in why floats don't have decent orderings.

@jonhoo
Copy link
Owner

jonhoo commented Feb 10, 2019

One trick we could play here is to upsample by, say, 100x, and then keep using usize 🤔

@jonhoo jonhoo added enhancement New feature or request help wanted Extra attention is needed labels Feb 12, 2019
jasonrhansen added a commit to jasonrhansen/inferno that referenced this issue Feb 25, 2019
@jasonrhansen
Copy link
Collaborator

As far as I can tell there is no reason TimedFrame needs to be Eq or Hash. Frame is used as a key in a HashMap, but it doesn't have any fields relating to samples. TimedFrame is only ever stored in a Vec. I think we should be able to use f64 for start_time, end_time, and delta, or am I overlooking something?

@jonhoo
Copy link
Owner

jonhoo commented Feb 27, 2019

I did some digging on this in #64 (comment), and my conclusion from reading brendangregg/FlameGraph#18 is that we should probably simply discard the fractional parts of samples, and add support for --factor instead.

@jasonrhansen
Copy link
Collaborator

#65 adds --factor instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants