This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Simplistic profiling with the runtime
charles.spirakis wrote:
> Enclosed is a simplistic example of using the runtime to generate time
> based profiling data. [...]
Nice.
> Has any discussion happen on what we want the systemtap translator
> syntax to look like in this regard? [...]
There are two aspects to it: hooking into the timer of your choice,
and having the pc->string decoding.
The plain jiffies-based timer has just received its own support in the
translator recently. Adding a new variant for this profiling timer
would not require much code. See the translator's src/tapsets.cxx,
look for "timer", near the bottom after all the strange dwarf stuff.
Second, the pc->string decoding function (get_image_path) would
probably need to be recast, probably in the form of an embedded-C
function and placed into tapset/SOMETHING.stp. It would take a PC
argument and return a string. A few more similar functions would be
needed to return the PC (REGS_IP(CONTEXT->regs->ip)), current->comm
(if any), rdtsc, etc.
Then, the final user script that ties it together might look like this:
global times, samples
probe timer.profiling(100) { # timer.jiffies(10) already works
s=rdtsc()
samples[comm(), pc(), path(pc())] ++
e=rdtsc()
times <<< e-s
}
probe end {
print "format1",samples
print "format2",times
}
... except that this code uses aggregates and the "print" statement,
neither of which are supported by the translator yet. It will be a bunch of weeks before we get to those.
Until then, one might not bother with the times aggregate (or use an
ordinary array, indexed with a manually quantized e-s value), and use
an explicit foreach() loop in "probe end" to print the array(s).
- FChE