[x264-devel] x264 threading performance

aviad rozenhek aviadr1 at gmail.com
Thu Oct 18 17:34:42 CEST 2007


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?
how many people are even using threads with x264?
is there someone who is actively developing in this direction? if not and
you think its a good idea, I think I can do it.

Regards
Aviad Rozenhek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.videolan.org/pipermail/x264-devel/attachments/20071018/43b5617d/attachment.htm 


More information about the x264-devel mailing list