Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@redhat.com>
To: linux-btrfs@vger.kernel.org
Subject: Systemtap script
Date: Wed, 5 Nov 2008 14:00:32 -0500	[thread overview]
Message-ID: <20081105190032.GA18270@unused.rdu.redhat.com> (raw)

Hello,

Since theres a _ton_ of calls its usually better to try and focus in on a set of
functions you are looking to screw with and that will keep the overhead from
going too high.  You can fiddle with the STP_OVERLOAD_THRESHOLD and
STP_OVERLOAD_INTERVAL variables to ramp the amount of overhead systemtap will
tolerate up, a good explanation of what they do and what the defaults are are in
the stap manpage.  Below is a simple stap script that I used to try and figure
out which function in the allocator was taking up so much time as everything
went along.  It just prints out how many times the function was called, the
average call time, min call time, max call time and total time spent since the
last print.  I find this page highly helpful

http://sourceware.org/systemtap/documentation.html

for figuring out different things, backtrace() is a helpful thing for getting a
backtrace.  You can do all sorts of tricky things, for example you can do
something like this to figure out how many times a particular call trace happens

some_variable[execname(),backtrace()] <<< 1

and then get stat information on that and print out the backtrace when you
process everything.  Thanks,

Josef


#!/usr/bin/env stap

probe module("btrfs").function("*@fs/btrfs/extent-tree.c") {
        calltime[tid()] = gettimeofday_us()
}

probe module("btrfs").function("*@fs/btrfs/extent-tree.c").return {
        now = gettimeofday_us()
        c = calltime[tid()]
        if (!c) next
        ttime[probefunc()] <<< now - c
        delete calltime[tid()]
}

probe timer.s(120) { print_stats() }

probe begin { printf("starting probe\n") }

function print_stats() {
        printf("\n")
        foreach (x in ttime)
                printf("%-20s\tcalls:%6d\tavg time (ms):%5d\tmin
time(ms):%5d\tmax time(ms):%5d\ttotal(ms):%7d\n",
                        x, @count(ttime[x]), @avg(ttime[x]), @min(ttime[x]),
@max(ttime[x]), @sum(ttime[x]))
        delete ttime
}

probe end { print_stats() }
global calltime, ttime


                 reply	other threads:[~2008-11-05 19:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081105190032.GA18270@unused.rdu.redhat.com \
    --to=jbacik@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox