Just an fyi,
Folks may already be using these python dtrace probes introduced in
python 2.4 for performance work in IPS:
http://blogs.sun.com/levon/entry/python_and_dtrace_in_build
But I was using them today to help me with some GUI performance issues
and thought I'd share the simple script I was using. Its just a hacked
version of Brendan Gregg's js_functime.d and I added a predicate to
allow me to specify which python file I wanted to focus on. Your mileage
may vary :) Helped me track a few startup and shutdown issues.
Is anyone doing perf work on IPS and if so have you been using DTrace or
the built in profile support in python itself?
JR
#!/usr/sbin/dtrace -Zs
/*
* py_functime.d - measure Python function times using DTrace.
*
* py_function-entry (filename, funcname, lineno)
*
* Usage: dtrace -s pyfunctime.d <python_file.py>
*/
#pragma ident "@(#)py_functime.d 1.0 26/08/08"
#pragma D option quiet
this string str;
dtrace:::BEGIN
{
printf("Tracing... Hit Ctrl-C to end.\n");
depth = 0;
self->count = 0
}
python*:::function-entry
/basename(copyinstr(arg0)) == $$1 /
{
self->depth++;
self->start[copyinstr(arg1), self->depth] = timestamp;
}
python*:::function-return
/basename(copyinstr(arg0)) == $$1 && (this->str = copyinstr(arg1)) != NULL &&
self->start[this->str, self->depth]/
{
this->file = basename(copyinstr(arg0));
this->elapsed = timestamp - self->start[this->str, self->depth];
@num[this->file, this->str] = count();
@eavg[this->file, this->str] = avg(this->elapsed);
@esum[this->file, this->str] = sum(this->elapsed);
@edist[this->str] = quantize(this->elapsed);
self->start[this->file, self->depth] = 0;
self->depth--;
}
dtrace:::END
{
normalize(@eavg, 1000);
normalize(@esum, 1000);
printf("ELAPSED TIME DISTRIBUTION,\n");
printa(@edist);
setopt("aggsortpos", "2");
printf("%-33s %45s\n", "___ OVERLAP TIMES: ___",
"______ ELAPSED _____");
printf("%-24s %-23s %6s %10s %12s\n", "FILE", "FUNCTION",
"COUNT", "AVG(us)", "SUM(us)");
printa("%-24.24s %-23.23s [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL
PROTECTED]", @num, @eavg, @esum);
}
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss