The 2.6.25 kernel of linux has a new feature called "support for latency measuring". (http://kernelnewbies.org/Linux_2_6_25)
Basically what this means is that, with a tool called Latencytop, we can measure process latencies (the time that a process waits,
for different resource access), and get a report for latencies for each process and for the whole system. (http://latencytop.org/announce.php)
A sample output is pasted below:
Cause Maximum Percentage
fsync() on a file 1351.0 msec 14.5 %
Deleting an inode 79.9 msec 0.9 %
Creating directory 30.5 msec 0.5 %
Scheduler: waiting for cpu 28.5 msec 55.8 %
Waiting for event (select) 5.0 msec 19.3 %
Waiting for event (poll) 5.0 msec 7.8 %
Userspace lock contention 4.4 msec 0.3 %
SCSI ioctl command 1.8 msec 0.1 %
Receiving TCP/IP data 1.1 msec 0.8 %
This can be used to identify bottlenecks in a system, and tune it appropriately.
I evaluated this tool and found it interesting.
Here is the step that I followed to get it working..
1. download vanilla kernel sources (2.6.25)
2. Enable the option CONFIG_LATENCYTOP in the menuconfig (so that the kernel can be told to collect these statistics)
3. build and boot with the new kernel.
4. download the latencytop source from (http://latencytop.org/announce.php)
5. make and make install latencytop
6. run sudo ./latencytop, and you get the report above.
There is very little documentation on this tool, as it is very recent. So reading the code of the program is the only way to understand some options.
I figured out that basically it keeps a list of all processes running, and in a round robin fashion, polls the latencies of these list of processes periodically.
The default period is 30 seconds, but you can change the function update_display() in the latencytop.c to get the polling period that we want.
I guess this, along with the "latency queries" of gstreamer pipelines could be useful in some way to trim down latencies in media pipelines. Any ideas ?