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

Search slightly undercounts when matching many tiny frames #140

Closed
brendangregg opened this issue Aug 5, 2017 · 2 comments
Closed

Search slightly undercounts when matching many tiny frames #140

brendangregg opened this issue Aug 5, 2017 · 2 comments

Comments

@brendangregg
Copy link
Owner

brendangregg commented Aug 5, 2017

I'll create an extreme example to highlight it, by creating an artificial folded file with 100 tiny frames:

for i in `seq 1 100`; do echo "big_a;big_b;big_c;big_d;big_e;big_f;big_g;tiny_h$i 1"; done > search_test.txt
echo "big_x;big_y;big_z 100" >> search_test.txt
./flamegraph.pl < search_test.txt > search_test.svg

If you Ctrl-F search for "big_g", it matches 50%. As it should.

But if you Ctrl-F search for "tiny", it matches 45.5%. We've lost 0.045% for each matched frame.

This sounds like a rounding issue in the JavaScript search code. These are adjacent in the svg:

<g class="func_g" onmouseover="s(this)" onmouseout="c()" onclick="zoom(this)">
<title>tiny_h11 (1 samples, 0.50%)</title><rect x="27.7" y="33" width="5.9" height="15.0" fill="rgb(248,191,42)" rx="2" ry="2" />
<text text-anchor="" x="30.70" y="43.5" font-size="12" font-family="Verdana" fill="rgb(0,0,0)"  ></text>
</g>
<g class="func_g" onmouseover="s(this)" onmouseout="c()" onclick="zoom(this)">
<title>tiny_h12 (1 samples, 0.50%)</title><rect x="33.6" y="33" width="5.9" height="15.0" fill="rgb(230,70,1)" rx="2" ry="2" />
<text text-anchor="" x="36.60" y="43.5" font-size="12" font-family="Verdana" fill="rgb(0,0,0)"  ></text>
</g>
<g class="func_g" onmouseover="s(this)" onmouseout="c()" onclick="zoom(this)">
<title>tiny_h13 (1 samples, 0.50%)</title><rect x="39.5" y="33" width="5.9" height="15.0" fill="rgb(215,130,36)" rx="2" ry="2" />
<text text-anchor="" x="42.50" y="43.5" font-size="12" font-family="Verdana" fill="rgb(0,0,0)"  ></text>
</g>

So the "x" and "width" variables show that these's no space between these frames. It's the widths that are summed to get the total percent, and the size of the "big" frames is 590, so 100 x 5.9 == 590. So this approach should work, but we're losing a tiny bit. This tells me that the problem is not the Perl code, but the JavaScript code that's adding the widths. (JavaScript floating point?)

@cwarden
Copy link

cwarden commented Aug 8, 2017

Yep, looks like another floating point problem.

2017-08-08-143129_1170x470_scrot

Work-around it like in zoom?

@brendangregg
Copy link
Owner Author

thanks. I'm very glad that variable is called "fudge" -- makes it easy to remember what it's for!

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

2 participants