Difference between revisions of "Profile/Systemtap"
Line 49: | Line 49: | ||
=== Using with sugar-buid === | === Using with sugar-buid === | ||
− | In sugar-build, we build glib, then we need move the global glib and gobject probes, to not have | + | In sugar-build, we build glib, then we need move the global glib and gobject probes, to not have conflicts. |
I renamed the global probes: | I renamed the global probes: | ||
Line 59: | Line 59: | ||
Now we can download a sample test, like [http://people.gnome.org/~walters/glib-memtrace2.stp] and run it in our sugar-build session. | Now we can download a sample test, like [http://people.gnome.org/~walters/glib-memtrace2.stp] and run it in our sugar-build session. | ||
− | To | + | To define as target a running process, can use the -x parameter. (Remember stap monitor all the system) |
To get the sugar process PID, can do: | To get the sugar process PID, can do: |
Revision as of 15:00, 10 March 2014
Using Systemtap to profile Sugar
In my system (Fedora 18) I found a bug [1] and needed install systemtap from git. Newer systems can have it solved.
Installing systemtap from git
The installation is very standard, requieres set a destination directory:
$ git clone git://sourceware.org/git/systemtap.git $ cd systemtap/ $ ./configure --prefix=/home/gonzalo/systemtap-2.5-27886 $ make $ make install
Installing from repositories
You can try install from repositories too.
# yum install -y systemtap-devel systemtap-runtime systemtap-client
If you install from git and from the repositories, in the same system, can have conflicts trying to run the probes.
Adding your user to the needed groups
To run stap as a user, you need add it to the following groups
# usermod -a -G stapusr gonzalo # usermod -a -G stapsys gonzalo # usermod -a -G stapdev gonzalo
after that, you need restart your session.
You always can run stap as root too.
Using systemtap
Systemtap have "probes" already included in the kernel, and several libraries in user space too. Both GLib and python have probes, making it very useful for us. You can use it to monitor when files are read, or when objects are created or destroyed. To do it, have a language to create scripts. Several scripts are already created, and you can create new or modify them.
Systemtap monitor events in all the process in the system, but you can define a filter to monitor only a specific process.
This example show how to analyze memory use with SystemTap [2]
Using with sugar-buid
In sugar-build, we build glib, then we need move the global glib and gobject probes, to not have conflicts.
I renamed the global probes:
# cd /usr/share/systemtap/tapset/ # mv 64-glib.stp 64-glib.stp.old # mv 64-gobject.stp 64-gobject.stp.old
Now we can download a sample test, like [3] and run it in our sugar-build session.
To define as target a running process, can use the -x parameter. (Remember stap monitor all the system)
To get the sugar process PID, can do:
$ ps ax | grep jarabe 24673 ? Sl 0:28 python2 -m jarabe.main
The first number is the PID
Running stap with the PID we found:
$ stap -v -x 24673 glib-memtrace2.stp
This will show every 5 seconds, the memory use and if GObjects were created.
Another probe you can use is File:Pyfuntime.stp
$ stap -v -x 24673 pyfuntime.stp
Will show every time a python method start and finish, and the time spent.
Finally, to have a "top" like of python functions, download File:Pyfuntop.stp
Troubleshoting
- If your user can't run stap, execute the command "groups" and check if stapusr, stapsys and stapdev groups are present.
- If you need check what directories is using systemtap to look for the probes, can do:
stap -p1 -vv 'probe begin { }' > /dev/null
External links
Systemtap wiki https://sourceware.org/systemtap/wiki