Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linear aggregation #37

Open
brendangregg opened this issue Nov 12, 2013 · 3 comments
Open

linear aggregation #37

brendangregg opened this issue Nov 12, 2013 · 3 comments

Comments

@brendangregg
Copy link

Something that seems missing is an easy way to bucketize data, such as a linear aggregation. For example, I want to store latency in 10 ms buckets, from 0 to whatever the maximum observed latency is, and print it out as a histogram.

Here's an example workaround using the current capabilities. First, the example output:

# ./sysagg.kp 
Tracing syscalls... Hit Ctrl-C to end.
^C
   LAT(ms)+    COUNT
          0      378
         10        0
         20        0
         30        1
         40        0
         50        0
         60        0
         70        2
         80        0
         90        0
        100       33
        110        0
        120        2
        130        0
        140        2
        150        0
        160        2

This would be even better as a histogram.

And the script:

#!/usr/bin/env ktap
#
# sysagg.kp syscall latency linear aggregation
#
#10-Nov-2013   Brendan Gregg   Created this

step = 10   # number of ms per step

self = {}
lats = {}
max = 0

print("Tracing syscalls... Hit Ctrl-C to end.")

trace syscalls:sys_enter_* {
    self[tid()] = gettimeofday_us()
}

trace syscalls:sys_exit_* {
    if (self[tid()] == nil) { return }
    delta = (gettimeofday_us() - self[tid()]) / (step * 1000)
    if (delta > max) { max = delta }
    lats[delta] += 1
    self[tid()] = nil
}

trace_end {
    printf("   %8s %8s\n", "LAT(ms)+", "COUNT");
    for (i = 0, max, 1) {
        printf("   %8d %8d\n", i * step, lats[i]);
    }
}
@ktap
Copy link
Owner

ktap commented Nov 12, 2013

Hi Brendan,

You are right, there also lack data bucketize functionality in ktap,
I will take look at deeply to find out a proper design for ktap.

Hopefully this line aggregation and key sorting functionality will
be support in next release(v0.4).

And again, do you willing to let this script to be a sample script
in ktap tree?

Thank you very much.

Jovi

@brendangregg
Copy link
Author

Thanks, data bucketize will be useful. Yes, you are welcome to include it in the ktap tree; it's from a simple page I created of ktap examples (http://www.brendangregg.com/ktap.html). Not much there yet, but as I use ktap more I will probably come up with more things that might be useful to include.

@ktap
Copy link
Owner

ktap commented Nov 18, 2013

Thank you very much, that page would be a good tutorial for ktap. :)

(I will keep this issue open until ktap support linear aggregation, and other two issues.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants