2
votes

I have a problem where my application scales linearly with the number of threads(think 800 threads gives doubly the performance of 400 threads on dual core CPU). And my gut feeling is telling me that threads are sleeping or are being blocked... but I cant see it in callgrind.

So does callgrind measure function time, or just the time that thread was active to create data. If it is not clear what I ask... thread does

i ++;

for 2 seconds, then

sleep(1);//thread will not be scheduled to run for min 1 second...  

... will i++ be approximately 100% or approximately 66% of the call graph.

1
After fixing some grammar and markup, I still do not really understand your question. - Sebastian Mach
It will be approximately 100% (but why don't you try it and see?) - n. 1.8e9-where's-my-share m.
Eg .During 45 seconds of execution time thread X was running for 22 second... Does Valgrind when it calculates call graph does calculations on those 22 second or entire 45 seconds... Another eg. if thread blocks on network rcv is that waiting part of the time that is reported... ? - NoSenseEtAl
@n.m is there a way to get data with sleeping and blocking measured ? I didnt try it becuase it is not trivial to measure if call to blocking function is being registered as time spent..., sleep was just an example - NoSenseEtAl
Not sure I understand the question, in general call grind measure CPU instructions, not time, which would be heavily distorted by valgrind's slowness anyway. If you want to measure realistic times, better use a sampling profiler like sysprof. (On a side note, I don't see how 400 threads on a dual core can do anything but sleep most of the time) - Frank Osterfeld

1 Answers

1
votes

Valgrind collects user time statistics, not real time statistics. So if threads are interrupting each other, you won't see it in Valgrind. All you will get is the actual time spent executing each function.