Saturday, November 17, 2007



To start off, just a disclaimer...
I've not done any GNOME/GTK development ever nor am I very experienced in GUI programming. What I'm hoping to get out of this is; 1) Experience with GNOME/GTK, 2) Experience with debugging and 3) A super fast menu system :-)

And off course, chances are that posts that has nothing to do with Slab finds is way here as well.

So this is my first post about Slab, the new GNOME Main Menu. I'm currently looking at ways to make it perform as it was on drugs.

I will start off by profiling the Application Browser (AB).

In order to improve performance, one should start by profiling the application. At least that's what Federico says, so that is what I will do :-)
After profiling is complete, one needs to decide what to optimize. Again, Federico says that you can't optimize without having goals, and again, I will obey.

I've actually already cheated and done some profiling that I posted on the openSUSE wiki. But for the purpose of this blog, I will start all over :-)

So the first thing to do is to add some debug code. I'm going to use the following (very simple, but yet not very elegant function :-)

void timeCount(char *funcName)
struct timeval tv;
gettimeofday(&tv, NULL);
long tms;
int i = 0;
int func = -1;
char *formatted, *str;

tms = tv.tv_sec * 1000 + tv.tv_usec / 1000;

while(lapse[i].last) {
if(!strcmp(funcName, lapse[i].funcName)) {
func = i;

if(func == -1)
func = i;

if(!lapse[func].last) {
strcpy(lapse[func].funcName, funcName);
lapse[func].hello = 0;

if(!lapse[func].init) {
lapse[func].last = tms;
lapse[func].init = 1;
lapse[func].hello += 1;
str = g_strdup_printf ("MARK: %s: %s Begin", g_get_prgname(), funcName);
else {
lapse[func].curtime = (tms-lapse[func].last)+lapse[func].curtime;
lapse[func].init = 0;
str = g_strdup_printf ("MARK: %s: %s End", g_get_prgname(), funcName);

access (str, F_OK);
g_free (str);

Now I need to add this function to the beginning and end of various functions that I want to profile. I also add an exit statement in the application instead of calling gtk_main(). This allows me to run in batch mode without having to kill AB.

Then I start the application as follows;
strace -ttt -f -o test-strace.log application-browser

Once done, I use to generate a pretty picture.

The end result becomes this;

And this (Second column is the number of times the function was called and the third column is the total time spent in that function);

"generate_categories ==> gmenu_tree_get_root_directory (app_data->tree)","1","854"

After sprinkling some more debug code (and also added the option to not include a specific function in the plot), the result is;

"generate_categories ==> gmenu_tree_get_root_directory (app_data->tree)","1","860"

Running the same as above, but without strace will render completely different numbers. So for the sake of being able to create pretty pictures throughout this exercise, strace will only be used when we need to create a new pretty picture and we can then compare that to what we have above. The numbers below were generated without using strace.

"generate_categories ==> gmenu_tree_get_root_directory (app_data->tree)","1","337"

1 comment:

Michael Wolf said...

Can you configure your feed to not truncate entries?