|
From: Josef W. <Jos...@gm...> - 2008-08-08 11:01:28
|
On Friday 08 August 2008, Anish Anto wrote: > However, i have been finding that my App. which for a normal single run > takes total 10 secs(cpu time) and one of its functions FUN() takes 0.98 > secs(cpu time)- thats 10% of total cpu time , however when run with > Valgrind like this valgrind --tool=callgrind ./Release/MYAPP, takes about > total 600 secs and the function FUN() takes about 200 secs - thats 33% of > the total cputime. As already said, runtime instrumentation as done by Valgrind totally perturbates time behavior of the application, so any wallclock measurement done within a Valgrind run is bogus. However, Cachegrind/Callgrind does not do any such wallclock measurement but only count synthetic cache events like hits/misses and instruction executions, so ... > Kcachegrind does show me that percentage of time spend > at FUN() as 33%, which is true when app is run using Valgrind, however > just 10% when run without using Valgrind/Kcachegrind. ... I do not understand what "time" you are talking about here. KCachegrind does have a derived event type "estimated cycle time", which is calculated very roughly from the events counted, but you can not really expect this to have much relation to reality. As this only takes cache hits/misses into account, it is only kind of valid if (1) the runtime of your program is heavily influenced by bad cache behavior (it can not say anything about cycles wasted in branch misprediction, pipeline conflicts, bus congestions) (2) the coefficients of the "estimated cycle time" formula for average stall times of L1/L2 misses are adjusted to your system (the default is 100 cycles for L2 miss, and 10 cycles for L1 miss) You always also should use real time measurements to check any improvements. Callgrind/Cachegrind can just gave hints about potential time wasters in your code. Josef > Well, its understandable that running app using Valgrind has an additional > overhead - hence 600 secs CPU time with valgrind is compared with 10 secs > CPU time without valgrind. > However, my assumption was that the realtive percentage usage within the > functions should have remained the same , -eg 10% usage at function FUN(), > should have remained exactly 10% even on running valgrind, however why > does Valgrind/Kcachegrind show me as 33% ? > > Thanks > Anish > > > |