1

I used ruby-prof to generate stack call graph. It generates its very nice, but it shows only 3 of like 10 calls inside the method. These 3 calls, according to timing consume like 100% time inside this method. I assume that other calls are not shown, because they are very fast, and don't affect performance. Am I right?

Sławosz
  • 11,187
  • 15
  • 73
  • 106
  • 3
    If you can, show the data (maybe obfuscate the names if it is company IP). Otherwise we have to imagine what you are looking at before answering, and that is likely to lead to mistakes. – Neil Slater Apr 05 '16 at 14:49
  • Well, data is quite hard to show, lot of stuff there and its private code. I will try later to run it with ie rails stuff or some simple app, and then link results. – Sławosz Apr 05 '16 at 15:06
  • Just show the parts you are having trouble with, not the whole graph. – Neil Slater Apr 05 '16 at 15:08
  • 1
    Remember that profilers are often statistical and not absolute. If these methods are very brief in execution they might be missed by the sampler. To get better data you need to run your code longer. – tadman Apr 05 '16 at 15:16
  • @tadman great comment! I actually have tiny probe, it may be the thing :) – Sławosz Apr 05 '16 at 15:59
  • @tadman: I assume the profiler is a stack sampler. What matters is not how fast a call is, but what fraction of time it is responsible for. If that fraction is significant, the sampler will see it, no matter how fast it is. Sławosz, don't expect the call graph to tell you how to speed up the code. [*There are better ways.*](http://stackoverflow.com/a/25870103/23771) – Mike Dunlavey Apr 05 '16 at 16:15
  • @MikeDunlavey There are cases where methods that use <0.1% of the CPU time might be invisible, they literally fall through the cracks. They might not appear in any stack samples. – tadman Apr 05 '16 at 22:20
  • @tadman: a routine that is responsible for 1% (the sum over *all* invocations of it) or less is not significant - if the goal is to find speedups. Sometimes people go into performance tuning with the assumption that they are looking for small stuff - i.e. assuming the code is close to optimal to begin with - wishful thinking. Serious work requires looking for the big stuff, especially the [*big stuff that hides from profilers*](http://programmers.stackexchange.com/a/302345/2429), and big stuff does not need many samples. After fixing big stuff, the small stuff may become big; then go for it. – Mike Dunlavey Apr 06 '16 at 12:48
  • @MikeDunlavey Totally hear you, but the question was why some of the method calls that are clearly in the code were not showing up. – tadman Apr 06 '16 at 16:20
  • @tadman: You're right. It's a tricky/ambiguous question. For better or worse, I tend to assume performance is what people actually care about, even while they struggle to word a profiling question. – Mike Dunlavey Apr 06 '16 at 17:52

0 Answers0