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

Steven Liu lingjiujianke at gmail.com
Wed Jun 19 13:39:09 EEST 2024


Nuo Mi <nuomi2021 at gmail.com> 于2024年6月19日周三 16:40写道:
>
> On Tue, Jun 18, 2024 at 8:06 PM Steven Liu <lingjiujianke at gmail.com> wrote:
>
> > Nuo Mi <nuomi2021 at gmail.com> 于2024年6月18日周二 19:51写道:
> > >
> > > 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?
> > Just control CPU resource be used by decoder, perhaps the computer is
> > running some other applications.
> > There are running more application in one computer, and the ffmpeg
> > decoder is need not realtime.
> > For example running machine learning traning some model, and use
> > ffmpeg transcoding vod videos,
> > but transcode functions is borrow machine learning's team computers :D.
> >
> You can use "taskset" for CPU affinity. It will constrain the CPU resources
> used by a process.
it is one way, only ok out of containers, and that should can be
control by ffmpeg self.
maybe cpu_count is ok, but not only this one scene, as zhili said,
that is the other scene.


More information about the ffmpeg-devel mailing list