[FFmpeg-devel] [PATCH 1/2] avutil/executor: Allowing thread_count be zero

Nuo Mi nuomi2021 at gmail.com
Wed Jun 19 11:51:20 EEST 2024


On Tue, Jun 18, 2024 at 10:24 PM Zhao Zhili <quinkblack at foxmail.com> wrote:

>
>
> > On Jun 18, 2024, at 19:50, Nuo Mi <nuomi2021 at gmail.com> wrote:
> >
> > On Mon, Jun 17, 2024 at 5:28 PM Zhao Zhili <quinkblack at foxmail.com>
> wrote:
> >
> >>
> >>
> >>> On Jun 17, 2024, at 16:45, Hendrik Leppkes <h.leppkes at gmail.com>
> wrote:
> >>>
> >>> On Mon, Jun 17, 2024 at 10:03 AM Zhao Zhili <quinkblack at foxmail.com>
> >> wrote:
> >>>>
> >>>>
> >>>>
> >>>>> On Jun 17, 2024, at 15:05, Anton Khirnov <anton at khirnov.net> wrote:
> >>>>>
> >>>>> Quoting Zhao Zhili (2024-06-17 07:19:26)
> >>>>>> From: Zhao Zhili <zhilizhao at tencent.com>
> >>>>>>
> >>>>>> When thread_count be zero, it will be run on current thread like
> >>>>>> !HAVE_THREADS.
> >>>>>
> >>>>> Other APIs treat zero to mean "auto".
> >>>>
> >>>> executor don’t detect cpu cores by itself. It’s more low level than
> >> libavcodec.
> >>>>
> >>>> Zero thread is zero thread, literally. If we use thread_count one to
> >> mean
> >>>> run on current thread, how to create a single thread then?
> >>>
> >>> Whats the point of creating a single thread? Does the main thread ever
> >>> do something else in the meantime, or does it just wait for the job
> >>> anyway?
> >>
> >> Executor as a basic infrastructure should support such usage. The caller
> >> don’t need to wait for the job to finish.
> >>
> > Hi Zhili,
> > Thank you for the patch.
> > Could you explain more about its usage?
> > Why do we need to run everything in the main thread when we have pthread
> in
> > the system?
>
> In addition to match other decodes behavior, there are some usecases which
> require the decoder to not create a thread at runtime. For example, when
> build
> libavcodec with wasm and run in web browser, the runtime may or may not
> support threads, threads number should be decided at runtime, and can be
> zero.

Thank you for the details
Sounds reasonable if other code has the same behavior and we have real use
cases for this. Perhaps we can explain why we need this in the commit log.

Hi @Anton Khirnov <anton at khirnov.net>  and @Paul B Mahol <onemda at gmail.com>
Do you prefer -1? We need to return an invalid parameter for 0 if we use -1
to indicate zero threads.

Thank you.

>
>
> >
> > Thank you.
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list