diff mbox

[FFmpeg-devel,2/3] configure: speedup x2-x8

Message ID 1713344364.2595687.1535220597888@mail.yahoo.com
State New
Headers show

Commit Message

avih Aug. 25, 2018, 6:09 p.m. UTC
For overview see:
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-August/233665.html

Attached is patch 2/3 which was at "main.patch" of that message.

print_enabled_components() was invoking sed about 350 times on one
file. This is never instant but takes many seconds where fork is
slow (Windows). Invoke sed only once instead = x4-x10 speedup.
 

    On Saturday, August 25, 2018 7:55 PM, Timo Rothenpieler <timo@rothenpieler.org> wrote:
 

 Please use git send-email to send your patches, or at least send each 
patch, created by git format-patch, as individual attachment. Your files 
seem to contain multiple patches one after another, which makes them 
very hard to follow.

But nice work! Let's hope this does not cause any regressions.
diff mbox

Patch

From d1cf17fdb518b3a456bbac61e306599d0a4a7400 Mon Sep 17 00:00:00 2001
From: "Avi Halachmi (:avih)" <avihpit@yahoo.com>
Date: Mon, 30 Jul 2018 22:48:04 +0300
Subject: [PATCH] configure: print_enabled_components(): speedup x4 - x10

Inside print_enabled components, the filter_list case invokes sed
about 350 times to parse the same source file and extract different
info for each arg. This is never instant, and on systems where fork is
slow (notably MSYS2/Cygwin on windows) it takes many seconds.

Change it to use sed once on the source file and set env vars with the
parse results, then use these results inside the loop.

Additionally, the cases of indev_list and outdev_list are very
infrequent, but nevertheless they're faster, and arguably cleaner, with
shell parameter substitutions than with command substitutions.
---
 configure | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 465d808d..b74c44e7 100755
--- a/configure
+++ b/configure
@@ -7224,9 +7224,10 @@  echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
 
 cp_if_changed $TMPH libavutil/avconfig.h
 
-full_filter_name(){
-    sed -n "s/^extern AVFilter ff_\([avfsinkrc]\{2,5\}\)_$1;/\1_$1/p" $source_path/libavfilter/allfilters.c
-}
+# full_filter_name_foo=vf_foo
+# full_filter_name_bar=asrc_bar
+# ...
+eval "$(sed -n "s/^extern AVFilter ff_\([avfsinkrc]\{2,5\}\)_\(.*\);/full_filter_name_\2=\1_\2/p" $source_path/libavfilter/allfilters.c)"
 
 # generate the lists of enabled components
 print_enabled_components(){
@@ -7239,13 +7240,13 @@  print_enabled_components(){
         if enabled $c; then
             case $name in
                 filter_list)
-                    c=$(full_filter_name $(remove_suffix _filter $c))
+                    eval c=\$full_filter_name_${c%_filter}
                 ;;
                 indev_list)
-                    c=$(add_suffix _demuxer $(remove_suffix _indev $c))
+                    c=${c%_indev}_demuxer
                 ;;
                 outdev_list)
-                    c=$(add_suffix _muxer $(remove_suffix _outdev $c))
+                    c=${c%_outdev}_muxer
                 ;;
             esac
             printf "    &ff_%s,\n" $c >> $TMPH
-- 
2.17.1