rtspsrc cpu optimization

Sebastian Dröge sebastian at centricular.com
Wed Oct 22 00:32:31 PDT 2014


On Di, 2014-10-21 at 18:55 -0400, Eloi Bail wrote:
> I manage to have significant CPU consumption improvement reducing
> frequency of RTP reading.
> In gst_base_src_loop I added a 1ms sleep before calling gst_base_src_get_range.
> 
> My CPU consumption is then divided by 2 : 8-10% to 3-4%. The result
> (my mkv recorded file) looks ok.
> 
> Reducing reading frequency, we are using bigger buffers and pushing
> them less frequently. It also explains why I saw lot of time passed in
> gst_pad_push using profilers and also why removing mutex improved
> performance (pads were on use all the time and thus mutexs locked too)

Are we talking about RTSP with RTP over TCP or over UDP? With UDP you
should still get one RTP packet per read, and by adding the sleep you
risk running the kernel buffer full if there are on average more than 1
packet per ms.

> This workaround is dirty and I want to understand how to reduce socket
> reading frequency. Do you see a way to change it ?

I think as a next step it would be required to see where exactly the
high CPU usage comes from when reading from the socket, and then
optimize these bits. As we're talking about RTP here there's not much
you can do to get less packets (other than increasing the MTU or
lowering the stream's bitrate), so that part is rather fixed.

Which version of GLib are you using btw, and on which platform do you
run your application? Sorry if you mentioned that in an earlier mail
already.

-- 
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20141022/d457aa99/attachment-0001.sig>


More information about the gstreamer-devel mailing list