Message ID | e3c44286-0f68-34df-9ef8-8adbc4eb3e44@dehacked.net |
---|---|
State | New |
Headers | show |
On Thu, Nov 16, 2017 at 08:25:50PM -0500, DeHackEd wrote: > Hello, > > Simple one-line patch to avoid creating threads on a filtergrpah which does not > get used during execution. This saves a superfluous thread creation and > tear-down cycle. > > Besides cleanliness, the main driver for this feature is a system I have access > to with a large number of cores/threads. Threads count towards ulimits and the > default of 1 filtergraph thread per CPU thread is undesirable. > ffmpeg_filter.c | 1 + > 1 file changed, 1 insertion(+) > 8900e0a4dfa60c9c6c0f0612489d85080b213db8 0001-ffmpeg_filter-use-nb_threads-1-on-unused-filtergraph.patch > From 999a38ae38178c2ab3ba8a9ef116e7ec08474302 Mon Sep 17 00:00:00 2001 > From: DHE <git@dehacked.net> > Date: Thu, 16 Nov 2017 20:09:37 -0500 > Subject: [PATCH] ffmpeg_filter: use nb_threads=1 on unused filtergraph > > Signed-off-by: DHE <git@dehacked.net> > --- > fftools/ffmpeg_filter.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c > index aacc185..877fd67 100644 > --- a/fftools/ffmpeg_filter.c > +++ b/fftools/ffmpeg_filter.c > @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg) > graph = avfilter_graph_alloc(); > if (!graph) > return AVERROR(ENOMEM); > + graph->nb_threads = 1; if you checked that it doesnt reduce threads for simple & complex graphs that are used then LGTM thanks [...]
On 11/18/2017 05:56 AM, Michael Niedermayer wrote: > On Thu, Nov 16, 2017 at 08:25:50PM -0500, DeHackEd wrote: >> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c >> index aacc185..877fd67 100644 >> --- a/fftools/ffmpeg_filter.c >> +++ b/fftools/ffmpeg_filter.c >> @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg) >> graph = avfilter_graph_alloc(); >> if (!graph) >> return AVERROR(ENOMEM); >> + graph->nb_threads = 1; > > if you checked that it doesnt reduce threads for simple & complex > graphs that are used then LGTM > Yes I have verified that to be the case. Test method was $ strace -e trace=clone ./ffmpeg_g -filter_complex 'testsrc2[out]' ... The graph is disposed of within the same function. This is why I am proposing this change. Number of threads is a complex filtergraph is handled by the parameter -filter_complex_threads > thanks > > [...] > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
On Sat, Nov 18, 2017 at 11:15:55AM -0500, DeHackEd wrote: > On 11/18/2017 05:56 AM, Michael Niedermayer wrote: > > On Thu, Nov 16, 2017 at 08:25:50PM -0500, DeHackEd wrote: > >> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c > >> index aacc185..877fd67 100644 > >> --- a/fftools/ffmpeg_filter.c > >> +++ b/fftools/ffmpeg_filter.c > >> @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg) > >> graph = avfilter_graph_alloc(); > >> if (!graph) > >> return AVERROR(ENOMEM); > >> + graph->nb_threads = 1; > > > > if you checked that it doesnt reduce threads for simple & complex > > graphs that are used then LGTM > > > > Yes I have verified that to be the case. Test method was > $ strace -e trace=clone ./ffmpeg_g -filter_complex 'testsrc2[out]' ... ok, will apply thanks [...]
From 999a38ae38178c2ab3ba8a9ef116e7ec08474302 Mon Sep 17 00:00:00 2001 From: DHE <git@dehacked.net> Date: Thu, 16 Nov 2017 20:09:37 -0500 Subject: [PATCH] ffmpeg_filter: use nb_threads=1 on unused filtergraph Signed-off-by: DHE <git@dehacked.net> --- fftools/ffmpeg_filter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index aacc185..877fd67 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg) graph = avfilter_graph_alloc(); if (!graph) return AVERROR(ENOMEM); + graph->nb_threads = 1; ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs); if (ret < 0) -- 2.9.5