Currently, I'm analyzing the performance of a high latency application but I'm not confident in my measurements at all. So far, I have used DPROBES
for instrumentation and BCC/funclatency for measuring.
Would someone be able to verify those numbers? Also, if someone knows of a better method, please let me know.
measuring usleep(1)
: avg = 53962 nsecs
#include <unistd.h>
#include <sys/sdt.h>
int main() {
int i;
for(i=0; i<1000000; i++){
DTRACE_PROBE("hello-usdt", probe-main-start);
usleep(1);
DTRACE_PROBE("hello-usdt", probe-main-end);
}
}
measuring the overhead : avg = 788 nsecs
#include <sys/sdt.h>
int main() {
int i;
for(i=0; i<1000000; i++){
DTRACE_PROBE("hello-usdt", probe-main-start);
DTRACE_PROBE("hello-usdt", probe-main-end);
}
}
As an overhead, can I subtract 788 nsecs from all my measurements?
another example with nanosleep(200)
:avg = 52563 nsecs
#include <sys/sdt.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
int main() {
struct timespec tim, tim2;
tim.tv_sec = 0;
tim.tv_nsec = 200L;
int i;
for (i=0; i<100000; i++){
DTRACE_PROBE("hello-usdt", probe-main-start);
if(nanosleep(&tim , &tim2) < 0 ){
printf("Nano sleep system call failed \n");
return -1;
}
DTRACE_PROBE("hello-usdt", probe-main-end);
}
printf("Nano sleep successfull \n");
return 0;
}
A little modification was made to the funclatency
code:
# attach probes
usdt = USDT(path = "path to application")
usdt.enable_probe(probe = "probe-main-start", fn_name = "trace_func_entry")
usdt.enable_probe(probe = "probe-main-end", fn_name = "trace_func_return")
b = BPF(text = bpf_text, usdt_contexts = [usdt])
Am I unable to measure anything below 0.8usec with this method?
Furthermore I cannot believe that nanosleep(200)
"oversleep" by 50 usec.