Engine Profiling

From Spring
Revision as of 22:21, 12 November 2010 by Hoijui (talk | contribs) (initial post (raw data))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Development < Engine Profiling

Engine Profiling

Linux

there's several ways to profile an app profiling build is gprof way to profile, the compiler injects special code in the binary that self profiles it when it runs oprof way to profile is different, it uses statistical sampling, it's a kernel module every n clock ticks, it samples which current function is being processed it is leightweight, you can have it running with almost 0 performance impact (it also can profile your whole system) the downside of statistical profiling, is that it requires at least a certain sample size to achieve good accuracy oprof still requires the debug symbols, to resolve addresses into function names

but gprof requires special profiling flag

a) it doesn't interfere with normal program's work

 with spring, it gets so slow it's unusable for profiling anything in late game
 which is where it's needed the most
b) gprof requires special compiling options
c) with oprof, i can turn it on/off everytime i need
  so for instance i can skip spring loading
  you can also merge multiple profiling sessions

ok, you'll have to load the kernel module too you control the profiling daemon using opcontrol, as root as regular user, you can do post-processing using opreport i reccomend: callgraph depth of 16 --callgraph=16 separate each thread in it's own profile, you can always merge them using opreport afterwards also, per application profiles too ofc --separate=thread,library disable kernel profiling, enable userspace profiling

--event=CPU_CLK_UNHALTED:100000:0x0f:0:1 there should be a package with oprof, just install that then insmod oprofile as root


there's special statistical sampling timing functions in modern cpu my laptop's core 2 duo has them which somehow sets the lower bar generally for recent stuff :p

opcontrol --event=CPU_CLK_UNHALTED:100000:0x0f:0:1 --callgraph=16 --separate-type=thread,library that has to be sent only once & it will ve saved then, to start the profiler: opcontrol --start to stop: opcontrol --stop in order to make the profile data available to userspace, you'll need to dump the data opcontrol --dump

i use gprof2dot, which takes oprof data, and outputs a nice dot graph https://code.google.com/p/jrfonseca/wiki/Gprof2Dot then you can use either graphviz to render to a pic, or there are viewers that don't need so xdot lets you view it directly https://code.google.com/p/jrfonseca/wiki/XDot the result is something like this xdot-profile2.png you might need help to output the oprof data in a way that gprof2dot can digest, tell me when you reach there


Windows

<Please add>