Tuesday, 11 January 2011

CPU affinity Testing experiment

CPU affinity Testing experiment




Summary:
CPU affinity property has been added to the gstreamer plugins.
Objective of this test is to know whether the plugins respect the affinity that is assigned.


consider this simple pipeline
gst-launch fakesrc ! sleep ! fakesink

          (sleep is a plugin that has busy wait inside its chain function.)
This shows the following cpu load distribution. (red is one cpu and blue is another)
http://rosh/images/cpu_simple_1.jpg

Now, consider 2 sources, instead of 1
gst-launch fakesrc ! sleep ! fakesink  fakesrc ! sleep ! fakesink 



The graph looks like following:
http://rosh/images/cpu_simple_2.jpg
Obviously, the kernel was intelligent in scheduling it to two cores and the two cpus where busy.

But, now with our cpu affinity setting fix, we could "force" the kernel to schedule both these plugins to the same core
as below:
gst-launch fakesrc ! sleep cpu_affinity=1 ! fakesink  fakesrc ! sleep cpu_affinity=1 ! fakesink 

Now, the picture  looks like this:
http://rosh/images/cpu_simple_3.jpg
http://rosh/images/cpu_simple_4.jpg

This means, that we are able to schedule the plugins to the core we want, using the cpu_affinity property that we have added.
"sleep" could be replaced with any other plugin, that we may be interested in.

- Rosh
31 Oct 2008