This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Better handling of arguments/literals from the command-line?


Hi Ted,

On Sun, 2008-10-05 at 00:21 -0400, Theodore Ts'o wrote:
> I discovered to my dismay that this script took a full 45 seconds before
> it started, and consumed 100% of one CPU while it was compiling it.  I
> further found that each time I gave this script a new pid on the command
> line, it took another 45 seconds.  If I gave it a pid that it had seen
> before, it only took 10 seconds.  Leaving aside why it took a full 10
> seconds (which still seems too long) even when the scripts for a
> particular pid was cached, it seems rather unfortunate that literals
> such as $1 appear to be substituted in early in the compilation process
> instead of being passed in when the module is loaded, as arguments to
> the module.   

It is less than 10 seconds on my machine, but still some seconds. Which
does indeed seem somewhat long if we can find the cached files
eventually.

> If the argument were passed into the kernel, then it would be posible to
> cache the compiled "strace.stp" script once, instead of having to
> re-evaluate it for every single process ID.  Is there a good reason it
> isn't handle this way currently?

You can get that effect by using the target() function.
And using stap -x pid or stap -c exe:

strace.stp:

        probe syscall.* {
            if (pid() == target()) {
                t = gettimeofday_ms();
                printf("%d:%03d:%s(%s)\n", t/1000, t%1000, name, argstr)
            }
        }
        
        probe syscall.*.return {
            if (pid() == target()) {
                t = gettimeofday_ms();
                printf("%d:%03d;%s returns %s\n", t/1000,t%1000, name, retstr)
            }
        }


$ stap strace.stp -x 12345
or
$ stap strace.stp -c /bin/ls

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]