Dynamic thread creation in Gstreamer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic thread creation in Gstreamer

Mattias Barthel
Hi,

Is there a way to configure Gstreamers behaviour regarding threads?
I would like that the threads would be created statically and not
dynamically.
(Have all worker threads created upon startup of a pipeline).


Mattias

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic thread creation in Gstreamer

michael smith-6-3
On Thu, Jun 26, 2008 at 12:31 AM, Mattias Barthel <[hidden email]> wrote:
> Hi,
>
> Is there a way to configure Gstreamers behaviour regarding threads?
> I would like that the threads would be created statically and not
> dynamically.
> (Have all worker threads created upon startup of a pipeline).
>

There's no way to configure or control this. However, that's what
GStreamer does - all threads are created upon startup of a pipeline.

Mike

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic thread creation in Gstreamer

Mattias Barthel
Ok, good to know that, thanks.

What I was seeing through gdb was the bezerk thread creation of x264enc.
x264enc creates a new thread for each frame it encodes.


Mattias

Michael Smith wrote:

> On Thu, Jun 26, 2008 at 12:31 AM, Mattias Barthel <[hidden email]> wrote:
>  
>> Hi,
>>
>> Is there a way to configure Gstreamers behaviour regarding threads?
>> I would like that the threads would be created statically and not
>> dynamically.
>> (Have all worker threads created upon startup of a pipeline).
>>
>>    
>
> There's no way to configure or control this. However, that's what
> GStreamer does - all threads are created upon startup of a pipeline.
>
> Mike
>
>
>  


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic thread creation in Gstreamer

Thomas Vander Stichele
On Fri, 2008-06-27 at 09:53 +0200, mattias wrote:
> Ok, good to know that, thanks.
>
> What I was seeing through gdb was the bezerk thread creation of x264enc.
> x264enc creates a new thread for each frame it encodes.

Are you sure about this ? That sounds very wrong.  Can you see where
this happens in the code ?

Thomas


--
yes i am
a long way
from home
--
Flumotion - the only way to stream!
http://www.flumotion.net/



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic thread creation in Gstreamer

Mattias Barthel
Thomas Vander Stichele wrote:

> On Fri, 2008-06-27 at 09:53 +0200, mattias wrote:
>  
>> Ok, good to know that, thanks.
>>
>> What I was seeing through gdb was the bezerk thread creation of x264enc.
>> x264enc creates a new thread for each frame it encodes.
>>    
>
> Are you sure about this ? That sounds very wrong.  Can you see where
> this happens in the code ?
>
> Thomas
>
>
>  
Another way of proving this is to launch a pipeline involving x264enc
and threads.

gst-launch videotestsrc ! x264enc threads=2 ! ffdec_h264 ! fakesink

And then in another terminal launch top -p <pid of gst-launch>,
the press 'H' for showing threads. Then lower to update interval of top
to 1s, press 's' and '1'.

You will see in top most commonly  2 threads but in some process
captures top will show you the third thread when it is alive as they
coincides.


Mattias

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic thread creation in Gstreamer

Mattias Barthel
In reply to this post by Thomas Vander Stichele
Thomas Vander Stichele wrote:

> On Fri, 2008-06-27 at 09:53 +0200, mattias wrote:
>  
>> Ok, good to know that, thanks.
>>
>> What I was seeing through gdb was the bezerk thread creation of x264enc.
>> x264enc creates a new thread for each frame it encodes.
>>    
>
> Are you sure about this ? That sounds very wrong.  Can you see where
> this happens in the code ?
>
> Thomas
>
>
>  
Yes,
If you specify to g_object_set on the property threads of the x264enc
element of just threads=2 in a gst-launch involving x264enc, then in the
library libx264.a the thread creation goes in that manner.

Have a look at encoder/encoder.c in the funcion
x264_encoder_encode(...), there x264_pthread_create is called with
x264_slices_write as thread function. Then in the function
x264_encoder_frame_end(...) the function x264_pthread_join is called to
join the finished thread after each frame. Now, what is not totally
clear to me is if the code really creates more than one extra thread.

So for each frame, at least one thread is created and killed!

Of course this behaviour creates a lot of overhead and it is quite bad
if you want to create a realtime application.

Mattias

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel