Profile Gnome using Dtrace

From WorkOutWiki2008

Jump to: navigation, search



Parthasarathi Susarla


Gnome users quite frequently get to a point when they feel fail to see the Gnome perform and crumbling under its own weight. As developers a lot of us have attempted to profile Gnome (and its applications), mostly unsuccessfully. And even if we get to profiling an application, post-processing is a nightmare. Also see presentation from Federico, where he repeatedly states the need to be able to profile Gnome. In this work-out we intent to provide means to solve concrete performance problems (like those listed on the Gnome Performance page using DTrace (DTrace Wikipedia page). The work-out intends to result in a adding DTrace probes to core gnome modules/libraries/applications such as glib/gtk. This would involve the coming together of Gnome developers and DTrace contributors and users.



Obviously you need to either be a Gnome Developer or a Solaris user/developer to benefit from and contribute to the session. Exposure to Gnome development would be very helpful. Since it involves using DTrace, a fair amount of DTrace knowledge is necessary to be able to help Gnome developers.

We are trying to provide virtual'ised images of OpenSolaris with the build environment. But it would be easier if the participants have OpenSolaris installed. OpenSolaris can be downloaded from here.

Also please read about the idea of these workouts here.

  MOST IMPORTANT : Please familiarize yourself with the entire Gnome build environment that OpenSolaris has to offer before arriving for the workout.

Languages, tools to be known

  • C (exposure to gtk/gnome programming is an advantage)
  • DTrace

Getting and compiling the code

  • Get OpenSolaris. The cds of OpenSolaris 2008.11 will be provided to the delegates.
  • Download and install SUNWhea / SUNWsfwhea / SUNWgnome-common-devel / SUNWperl-xml-parser / SUNWxorg-headers / SUNWgnome-xml packages using IPS
  • Instructions for building Gnome on OpenSolaris are available here.
  • After building the cbe a couple of things that you need to do:

- ln -s /opt/jdsbld/bin/m4 /usr/sfw/bin/gm4 -

  • we will have the sources made available on the day of the workout too.

Virtual Box images

We intend to provide virtual box images of OpenSolaris with the Gnome build environment in place. If you have not been able to install OpenSolaris please download and install Virtual Box on your Linux box.

Links to overall design/architecture

  • A short description as to how to add UserSpace DTrace (USDT) is available here.
  • The DTrace user-guide is a good place to start for getting an overall picture of how DTrace is/can be used.

Pre-event planning

Can document this here and/or add some links to Bugzilla, ML threads, other wiki pages


A few ideas:

  • With DTrace probes in all the right places, we can look at building something on the lines of Mortadelo
  • On the lines of the nautilus-logging infrastructure that Fedrico has written.

Some questions Dtrace can help answering once our probes are in place are:

  • What is the distribution of sizes of Gobjects that were allocated by the Gnome applications running?
  • What is the average time taken by various Gnome apps to respond to a particular event?

Existing work

  • Sample probes in the gksu module - apply this patch to the SUNWgksu.spec file to enable a sample DTrace probe:
Defining some DTrace flags to Makefile
   diff -up gksu-1.3.0-orig/gksu/ gksu-1.3.0/gksu/
   --- gksu-1.3.0-orig/gksu/    2008-11-22 17:04:06.733723000 +0530
   +++ gksu-1.3.0/gksu/ 2008-11-22 17:06:54.108966000 +0530
   @@ -124,6 +124,8 @@ CYGPATH_W = @CYGPATH_W@
    DEFS = @DEFS@
   +DTRACE = /usr/sbin/dtrace
   +DTRACE_FLAGS = -32 -G
    ECHO = @ECHO@
    ECHO_C = @ECHO_C@
    ECHO_N = @ECHO_N@
   @@ -243,6 +245,8 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/l
    noinst_HEADERS = defines.h util.h
    gksu_LDFLAGS = @GKSU_LIBS@ 
    gksu_SOURCES = gksu.c util.c
   +gksu_DTRACE_PROVIDER = gksu_probe.d
   +gksu_DTRACE_OBJECT = gksu_probe.o
    gksuexec_LDFLAGS = @GKSU_LIBS@
    gksuexec_SOURCES = gksuexec.c util.c
    configdir = /etc
   @@ -310,7 +314,8 @@ clean-binPROGRAMS:
    gksu$(EXEEXT): $(gksu_OBJECTS) $(gksu_DEPENDENCIES) 
           @rm -f gksu$(EXEEXT)
   -       $(LINK) $(gksu_LDFLAGS) $(gksu_OBJECTS) $(gksu_LDADD) $(LIBS)
   +       $(DTRACE) $(DTRACE_FLAGS) -s $(gksu_DTRACE_PROVIDER) $(gksu_OBJECTS)
   +       $(LINK) $(gksu_LDFLAGS) $(gksu_DTRACE_OBJECT) $(gksu_OBJECTS) $(gksu_LDADD) $(LIBS)
    gksuexec$(EXEEXT): $(gksuexec_OBJECTS) $(gksuexec_DEPENDENCIES) 
           @rm -f gksuexec$(EXEEXT)
           $(LINK) $(gksuexec_LDFLAGS) $(gksuexec_OBJECTS) $(gksuexec_LDADD) $(LIBS)
Adding the probe to the source file
   diff -up gksu-1.3.0-orig/gksu/gksu.c gksu-1.3.0/gksu/gksu.c
   --- gksu-1.3.0-orig/gksu/gksu.c 2008-11-22 17:04:06.740587000 +0530
   +++ gksu-1.3.0/gksu/gksu.c      2008-11-22 17:04:50.816835000 +0530
   @@ -17,6 +17,8 @@
    #include <gksuui.h>
    #include <gksu.h>
   +#include <sys/sdt.h>
    #include "defines.h"
    #include "../config.h"
   @@ -710,7 +712,7 @@ main (int argc, char **argv)
      bindtextdomain(PACKAGE_NAME, LOCALEDIR);  
      bind_textdomain_codeset (PACKAGE_NAME, "UTF-8");
      { /* support gksu_sudo_run */
        gchar *myname = g_path_get_basename (argv[0]);
        if (!strcmp(myname, "gksudo"))
   @@ -969,7 +971,7 @@ main (int argc, char **argv)
                                           NULL, NULL, NULL, NULL);
   +  DTRACE_PROBE1( gksu, gksu__invoke, gksu_context_get_command (context) ) ;
      if (sudo_mode)
          /* test if we can run without a password */
Adding the probe definition file
   --- /dev/null   2008-11-22 17:01:23.000000000 +0530
   +++ gksu-1.3.0/gksu/gksu_probe.d        2008-11-22 17:04:50.817256000 +0530
   @@ -0,0 +1,3 @@
   +provider gksu {
   +       probe gksu__invoke(char *) ;
   +} ;

Now "dtrace -n gksu*:::" should match one probe when the modified gksu binary is running.

Getting in touch

You can get in touch by email for now. Also. This page can be constantly updated as we go further.


  • Partha ( ajaysusarla AT gmail DOT com )
  • Surya Prakki ( Surya.Prakki AT sun DOT com )
  • Pramod Batni ( Pramod.Batni AT sun DOT com )
  • Vidya Sakar ( vidya.sakar AT gmail DOT com )
  • Krishnan Parthasarathi ( krishnan.parthasarathi AT gmail DOT com )
  • Hemantha Holla ( hemantha.holla AT gmail DOT com )



Personal tools