[linux-audio-dev] latencygraph 0.1, an API to profile userspace timings/latencies graphically , your opinions ?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] latencygraph 0.1, an API to profile userspace timings/latencies graphically , your opinions ?
From: Benno Senoner (sbenno_AT_gardena.net)
Date: ti helmi  01 2000 - 10:45:00 EST


Hi,

I developed a small API (called latency-graph 0.1), to profile the timing
behaviour of applications graphically. The graphs produced by the API are
similar to those produced by "latencytest".

For some problems it's quite useful to see the timing behaviour graphically,
because you can better identify peaks, mean values etc.
For example these diagrams were useful to profile the low-latency problems of
the kernel.
( A picture says more than 1000 words :-) )

For example it is uselful to see the timing behaviour of systemcalls
when the system load varies, or to compare the speed of the syscalls
across different kernel versions.

I encapsulated all stuff into functions and macros in order to provide
maximum ease of use.

the API is here: ( code + example code + detailed description + sample outputs)

http://www.linuxdj.com/latency-graph

let's show a short fragment of code:

we want to profile the behaviour of usleep(20000) during heavy system load
( heavy system load = heavy disk I/O, /proc stress, GFX output etc.)

the code below outputs the following graphs ( ignore the cyan line
because it's just a 2nd curve of usleep(50ms) (omitted in the sample code below)
Note the tests were run with SCHED_FIFO + mlockall() enabled

kernel 2.2.14 with untuned (DMA=off) IDE disk
http://www.linuxdj.com/latency-graph/test-2.2.14-nodma.gif

kernel 2.2.14 with tuned (DMA=on 32bit access=on unmask IRQ=on) IDE disk
http://www.linuxdj.com/latency-graph/test-2.2.14-dma.gif

kernel 2.2.10 + lowlatency patch with tuned IDE disk
http://www.linuxdj.com/latency-graph/test-2.2.10-lowlatency.gif
(can you say FLAT diagram ? :-) )

----
  //  starts recording
  lat_record_start();

for(i=0;i<1000;i++) { // check if there is still room left in the recording array, otherwise exit if(lat_check_samplerange) break;

// gets actual time in seconds 64bit floating point, should provide at least // usec accuracy

mytime1=lat_gettime();

// records the actual time (x-axis) lat_record_actual_time(mytime1);

// this is the function we want to profile, // as we see from the graphs usleep() sleeps 30ms instead of 20ms , and // the time varies as the system load increases usleep(20000);

// get the actual time after usleep() returns mytime2=lat_gettime();

// compute the difference delta=mytime2-mytime1;

// record the point into the first latency-curve (0) array lat_record_latency(0,delta); }

// draws the graph into the file named "test.gif"

draw_latency_graph("test.gif"); ----

Note that lat_init() zeroes all variables, in order to guarantee "hard realtime behaviour" lat_gettime() gets the the actual time with the best possible precison. (on x86 lat_gettime() = RDTSC + floating point division).

I (and maybe others) will use this tool to profile and optimize parts of the MuCoS multimedia API (still in the vaporware-stage but lots of brainstorming going on :-) ) ( http://www.linuxdj.com/mucos ).

One of the goals of MuCoS would be a way to communicate almost latency-free between multiple threads, with deterministic worst-case times. The single process case is already proven to work well thanks to Ingo's work, let's see if we can extend this to concurrent running threads.

Anyway I hope you will find this API useful for some of your profiling tasks.

Comments, ideas, suggestions ?

PS: For example for kernel programmers it would be interesting to port the profiling code to kernel space to allow graphical profiling of some of the kernel parts. (you have to avoid FP operations in kernel space, but that could be easily solved by storing the 64bit TSC counter values directly).

Benno.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:23:27 EST