EmergencyEMERGENCY? Get 24/7 Help Now!

SystemTap – DTrace for Linux ?

 | September 14, 2009 |  Posted In: Insight for DBAs


Since DTrace was released for Solaris I am missing it on Linux systems… It can’t be included in Linux by the same reason why ZFS can’t be – it’s licensing issue. Both ZFS and DTrace are under CDDL, which is incompatible with GPL. So you can see DTrace and ZFS on Solaris, FreeBSD, MacOS, but not on Linux.

However I follow the project SystemTap for couple of years (it was started in 2005), which is supposed to provide similar to DTrace functionality.

Why I am interested in this tool, because there is no simple way under Linux to profile not CPU-bound load (for CPU-bound there is OProfile, see for example
http://mysqlinsights.blogspot.com/2009/08/oprofile-for-io-bound-apps.html). I.e. for IO-bound or for mutex contention problems OProfile is not that useful.

SystemTap is included in RedHat 5 releases, but I was not able to get it running even in CentOS 5.3 (it crashed and hung every so often). Latest updated RedHat 5.4 promised some more fixes to SystemTap, so I decided to give it more try as soon as I got RedHat 5.4 on hands.

Surprising, but now it runs much more stable. I was able to get profiling of kernel and system calls.
Here is simple script to show IO activity per disk per process (well, it is similar to iotop, but iotop is not available in RedHat / CentOS)

with output like this

This example maybe is simple, but the point is that there is rich scripting language with tons
of probes you can intersect ( kernel functions, FS drivers functions, any other drives and modules)

What else I see very useful in SystemTap it can work in userspace. That is you can use it to profile your and any application that has -debuginfo packages ( all -debuginfo for standard RedHat RPMS you can download from RedHat FTP), but basically it is info you get compiling with


Well, there seems another war story going on. To profile userspace application with SystemTap your kernel should be patches with

patch, which fortunately is included in RedHat based kernels, but not included in vanilla kernel yet. So I am not sure if you can get userspace profiling running in another distributives.

There is quite simple script that I tried to hack around MySQL ®

with output which I get running simple SELECT against InnoDB table:

Again, this case is maybe too simple, but basically you can intersect internal MySQL function and script (measure time, count of call, statistics) what you what. I did not figure out yet how to intersect C++ style function (i.e.

), so there is area to investigate.

So I am going to play with it more and do some useful scripting to get profiling of MySQL.

And it seems SystemTap can re-use DTrace probes available in application, as you may know DTrace-probes were added into MySQL 5.4, so interesting how it works.

I should mention that there is second alternative of DTrace… It’s …. DTrace port. Looking on blog it seems one-man project and currently author is fighting with resolving userspace issues. I gave to this a try, but on my current RedHat 5.4 after several runs I got “Kernel panic”, so it’s enough for now.

Vadim Tkachenko

Vadim Tkachenko co-founded Percona in 2006 and serves as its Chief Technology Officer. Vadim leads Percona Labs, which focuses on technology research and performance evaluations of Percona’s and third-party products. Percona Labs designs no-gimmick tests of hardware, filesystems, storage engines, and databases that surpass the standard performance and functionality scenario benchmarks. Vadim’s expertise in LAMP performance and multi-threaded programming help optimize MySQL and InnoDB internals to take full advantage of modern hardware. Oracle Corporation and its predecessors have incorporated Vadim’s source code patches into the mainstream MySQL and InnoDB products. He also co-authored the book High Performance MySQL: Optimization, Backups, and Replication 3rd Edition.


  • > there is no simple way under Linux to profile not CPU-bound load
    > […]
    > I.e. for IO-bound or for mutex contention problems OProfile is not that useful.

    True, esp. when emphasing “simple”, and when compared to DTrace.
    But, beside SystemTap a couple of tools migth still give some help here:
    * blktrace , for I/O
    * the very recent “mutrace”, to track mutex contention (see http://0pointer.de/blog/projects/mutrace.html ).

    the point of this comment was to introduce mutrace indeed 😉

  • To get the real name of a C++ function you could use objdump:

    # objdump -t /usr/local/mysql/libexec/mysqld | grep index_read | grep ha_innoba |grep -v index_read_
    08269c80 g F .text 000002a9 _ZN11ha_innobase10index_readEPcPKcj16ha_rkey_function

    Unless it’s stripped:

    # file /usr/local/mysql/libexec/mysqld
    /usr/local/mysql/libexec/mysqld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
    # strip /usr/local/mysql/libexec/mysqld.stip
    # file /usr/local/mysql/libexec/mysqld.stip
    /usr/local/mysql/libexec/mysqld.stip: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
    # objdump -t /usr/local/mysql/libexec/mysqld.stip

    /usr/local/mysql/libexec/mysqld.stip: file format elf32-i386

    no symbols

  • Linux port of DTrace
    June 2009
    Paul D. Fox

    Blog – latest news and stuff about the dtrace project:
    Download dtrace tarballs for linux here:

  • popgo,

    I mentioned that tool at the end of post.
    Unfortunately when I tried it I got crashed server with Kernel panic error,
    so I would wait sometime before trying it in production.

  • Tony,

    You need only debug symbols to have that working. It is true for any package not only mysql.
    You can get debug symbols if you compile with CFLASG=”-g” CXXFLAGS=”-g”. Or alternative – there
    are available debug symbols packages almost for any software in CentOS distribution.

  • Ah cool, thanks for the quick replies, this site looks like a great resource for mysql tips – *bookmarks*

  • if I/O is your concern, you could look into blktrace and related tools


    the blkiomon command (part of the same package) seems very useful in particular, example:

    # blktrace /dev/sda -a issue -a complete -w 60 -o – | blkiomon -I 4 -h –

  • While I am was doing some test with SystemTap, I noticed two problems. Not sure, if there is anyone else ran into the same problems.

    1. The client session will be disconnected (MySQL server has gone away) after the SystemTap script is started or terminated.
    test@localhost [(none)]>select now();
    | now() |
    | 2011-07-27 19:58:39 |
    1 row in set (0.00 sec)

    test@localhost [(none)]>select now();
    ERROR 2006 (HY000): MySQL server has gone away
    No connection. Trying to reconnect…
    Connection id: 7
    Current database: *** NONE ***

    | now() |
    | 2011-07-27 19:59:04 |
    1 row in set (0.00 sec)

    2. When running the SystemTap script, command “alter table xxx truncate partition yyy” might hang. But if we terminate the running SystemTap script, the command will continue and success.

Leave a Reply


Percona’s widely read Percona Data Performance blog highlights our expertise in enterprise-class software, support, consulting and managed services solutions for both MySQL® and MongoDB® across traditional and cloud-based platforms. The decades of experience represented by our consultants is found daily in numerous and relevant blog posts.

Besides specific database help, the blog also provides notices on upcoming events and webinars.
Want to get weekly updates listing the latest blog posts? Subscribe to our blog now! Submit your email address below and we’ll send you an update every Friday at 1pm ET.

No, thank you. Please do not ask me again.