[x264-devel] x264 threading performance

Guillaume Poirier gpoirier at mplayerhq.hu
Thu Oct 18 17:44:18 CEST 2007


Hi,
aviad rozenhek wrote:
> Hi,
>  
> in encoder.c line 1477 we have:
> 
>     /* Write frame */
>     if( h-> param.i_threads > 1 )
>     {
>       x264_pthread_create( & h->thread_handle, NULL, (void
>     *)x264_slices_write, h );
>       h-> b_thread_active = 1;
>     }
> 
> IMHO, this approach might be flawed (at least on windows with
> pthreads-w32) because threads are not lightweight enough to be created
> and destoryed on every frame.
> 
> to get an impression it is easy to see how this affects performance by
> looking at the task manager:
> 
> when using only a single thread, almost all the cpu used (30% for
> 320x240) is used by the application (indicated in task manager by the
> green line).
> when using two threads (on my core 2 duo machine), significantly more
> cpu is utilized (50% for 320X240), and the difference is due to an increase
> in cpu used inside the kernel (indicated in task manager by the red line)
> 
> time spent in the kernel does is wasted when it could have been used for
> actually decoding.
> 
> my suggestion is to use a thread pool instead of creating and deleting
> threads.
> what do you think? do you believe its a good idea?

Mmmm... I think this problem is addressed by this patch:
http://akuvian.org/src/x264/x264_thread_pool.03.diff

Guillaume



More information about the x264-devel mailing list