Rockbox Technical Forums
Rockbox General => Rockbox General Discussion => Topic started by: lostlogic on December 03, 2005, 06:24:33 PM
-
Latest profiling patch, including the parser code is here:
http://lostlogicx.com/transfer/rockbox_profile.patch
Take output from the parser and compare two profiling runs with this perl script:
http://lostlogicx.com/transfer/profile_comparator.pl
Double link is deprecated, but available here: http://lostlogicx.com/transfer/profile-double-link.tar.gz
Design:
- Use -finstrument-functions option from GCC to automatically call profiling functions at entry and exit of each function to profile
- Implement the actual profiling functions under other names to avoid symbol duplication
- Implement small wrapper functions (indirection hurts) to export profiling symbols to APIs or wherever they to be used
- Add calls to switch_thread to shutdown and restart profiling
- Use a wrapper call in thread.c to initiate profiling so that the profiling code knows what thread it belongs to, in theory this could be extended so that we can have per-thread profiling states, but that is not the current situation
- Use statically allocated arrays in memory to store profiling data. I guessed at the sizes for these, there's gotta be a better way to size them to accomodate what is to be profiled
- Pulled from gmon.c in gcc (with credit given) a linked list like structure for profiling data wihch gives flexibility and reasonable speed to finding what counters to increment when
- Use #ifdef RB_PROFILE to keep dis code out when nothing's supposed to be profiled
- Time in functions is recorded in 100us increments.
- Profiling only runs on the thread it's started on so it doesn't have synchronization issues
- Profiling output format is functional, but PC based not symbol name based.
Things that need help:
- Currently I use the 'normal' user timer interface for timer creation, this means that when CPU frequency changes, the timer tries to stay the same length in time. For profiling, you want to measure length in clocks, not in time. We need a different timer initialization that does this. This is a low priority, because profiling is so slow that it's always boosted.
-
EEK, don't use the patch until I post a new version, it freezes.
-
Ok, so now it doesn't freeze, but the caller data is for the call _site_ not the top of the function... working on it. (same links, just updated)
-
Link updated again, now it has the right caller address, but it takes some more instructions to get it. This is somewhat less than stellar, but it works for now.
-
I like this. Keep up the good work and visit the IRC channel often. :-)
-
Wahoo, somewhat real results, will post a new patch shortly, I found the bug in my logic that was breaking with context switches.
[edit]New patch uploaded. This version works a lot better, and I pulled somestuff that was not relevent from the patch.[/edit]
-
http://lostlogicx.com/transfer/profile.debug.out
Here is some sample output from a long (about 1.5 songs) profiling run, and with the debug section of the output activated (that part inside #if(0) in the patch).
-
maybe i'm not reading it right...but what exactly does this do?
-
Google software profiling or gmon (GCC's profiling program) -- records call counts and time in functions for all functions executed within the profiled area of code.
-
More updates.
-
Now in two flavors!
-
Single link updated with much better parsing code that account for local symbols and exported symbols.
-
Submitted to patch tracker:
http://sourceforge.net/tracker/index.php?func=detail&atid=439120&group_id=44306&aid=1376651
-
can you dumb it down a little more? i don't understand your explanation, sorry :P (the closest they have to a drooling emote)
-
Software profiling is creating an execution profile of the software. Counting the time spent in every function (or those selected for profiling) and how many times it is called. This is very helpful for optimizing software, obviously, especially when the software's bottleneck is in CPU cycles as it is for decoding music on rockbox.
-
alright, cool. good work.
:P(drooling again) optimization=good