From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 4A75C385C412; Thu, 3 Feb 2022 15:40:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A75C385C412 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/fixinclude-speed-up)] Speed up fixincludes. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/fixinclude-speed-up X-Git-Oldrev: 67cd9cf5bfb5282be1cecaed90db095a7fe6d9f3 X-Git-Newrev: 0ba77db8a29ad1d98937d1deedbe1ad86638fc23 Message-Id: <20220203154053.4A75C385C412@sourceware.org> Date: Thu, 3 Feb 2022 15:40:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 15:40:53 -0000 https://gcc.gnu.org/g:0ba77db8a29ad1d98937d1deedbe1ad86638fc23 commit 0ba77db8a29ad1d98937d1deedbe1ad86638fc23 Author: Martin Liska Date: Thu Feb 3 15:49:43 2022 +0100 Speed up fixincludes. In my case: $ rm ./stmp-fixinc ; time make -j16 takes 17 seconds, where I can reduce it easily with the suggested change. Then I get to 11.2 seconds. The scripts searches ~2500 folders in my case with total 20K header files. fixincludes/ChangeLog: * fixinc.in: Use mkdir -p rather that a loop. Diff: --- fixincludes/fixinc.in | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in index de5a37f6acc..92f3dfc39a9 100755 --- a/fixincludes/fixinc.in +++ b/fixincludes/fixinc.in @@ -258,12 +258,23 @@ then echo "All directories (including links to directories):" echo $all_dirs fi -for file in $all_dirs; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done +ARG_MAX=`getconf ARG_MAX 2>/dev/null` +LENGTH=`expr length "$all_dirs" + 10` + +if test -n "$ARG_MAX" && test $LENGTH -lt $ARG_MAX +then + cd $LIB + mkdir -p $all_dirs + cd .. +else + for file in $all_dirs; do + rm -rf $LIB/$file + if [ ! -d $LIB/$file ] + then mkdir $LIB/$file + fi + done +fi + mkdir $LIB/root # # # # # # # # # # # # # # # # # # # # #