From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3lzv-0004lA-Gq for qemu-devel@nongnu.org; Mon, 07 Nov 2016 10:38:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3lzr-0008OX-JC for qemu-devel@nongnu.org; Mon, 07 Nov 2016 10:38:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c3lzr-0008OR-B4 for qemu-devel@nongnu.org; Mon, 07 Nov 2016 10:38:07 -0500 References: <1478103841-8686-1-git-send-email-pbonzini@redhat.com> <20161107124921.GG5036@stefanha-x1.localdomain> From: Paolo Bonzini Message-ID: Date: Mon, 7 Nov 2016 16:38:02 +0100 MIME-Version: 1.0 In-Reply-To: <20161107124921.GG5036@stefanha-x1.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.8?] rules.mak: speedup save-vars load-vars List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, famz@redhat.com On 07/11/2016 13:49, Stefan Hajnoczi wrote: > On Wed, Nov 02, 2016 at 05:24:01PM +0100, Paolo Bonzini wrote: >> Unnesting variables spends a lot of time parsing and executing foreach >> and if functions. Because actually very few variables have to be >> saved and restored, a good strategy is to remember what has to be done >> in load-vars, and only iterate the right variables in load-vars. >> For save-vars, unroll the foreach loop to provide another small >> improvement. >> >> This speeds up a "noop" build from around 15.5 seconds on my laptop >> to 11.7 (25% roughly). >> >> Signed-off-by: Paolo Bonzini >> --- >> I'm wondering if this would be acceptable for 2.8. >> I also have sent patches to GNU make that save another >> 20%, down to 9.8 seconds. >=20 > Sorry but I'd like to stick to the soft freeze policy. This patch is a > nice improvement but it's not a bug fix. Let's merge it for 2.9. Fine by me, thanks! Paolo >> rules.mak | 22 ++++++++++------------ >> 1 file changed, 10 insertions(+), 12 deletions(-) >> >> diff --git a/rules.mak b/rules.mak >> index 0333ae3..c0777d7 100644 >> --- a/rules.mak >> +++ b/rules.mak >> @@ -192,15 +192,15 @@ clean: clean-timestamp >> # save-vars >> # Usage: $(call save-vars, vars) >> # Save each variable $v in $vars as save-vars-$v, save their object's >> -# variables, then clear $v. >> +# variables, then clear $v. saved-vars-$v caches the list of variabl= es >> +# that were saved for the objects, in order to speedup load-vars. >> define save-vars >> $(foreach v,$1, >> $(eval save-vars-$v :=3D $(value $v)) >> - $(foreach o,$($v), >> - $(foreach k,cflags libs objs, >> - $(if $($o-$k), >> - $(eval save-vars-$o-$k :=3D $($o-$k)) >> - $(eval $o-$k :=3D )))) >> + $(eval saved-vars-$v :=3D $(foreach o,$($v), \ >> + $(if $($o-cflags), $o-cflags $(eval save-vars-$o-cflags := =3D $($o-cflags))$(eval $o-cflags :=3D )) \ >> + $(if $($o-libs), $o-libs $(eval save-vars-$o-libs :=3D $(= $o-libs))$(eval $o-libs :=3D )) \ >> + $(if $($o-objs), $o-objs $(eval save-vars-$o-objs :=3D $(= $o-objs))$(eval $o-objs :=3D )))) >> $(eval $v :=3D )) >> endef >> =20 >> @@ -213,12 +213,10 @@ define load-vars >> $(eval $2-new-value :=3D $(value $2)) >> $(foreach v,$1, >> $(eval $v :=3D $(value save-vars-$v)) >> - $(foreach o,$($v), >> - $(foreach k,cflags libs objs, >> - $(if $(save-vars-$o-$k), >> - $(eval $o-$k :=3D $(save-vars-$o-$k)) >> - $(eval save-vars-$o-$k :=3D )))) >> - $(eval save-vars-$v :=3D )) >> + $(foreach o,$(saved-vars-$v), >> + $(eval $o :=3D $(save-vars-$o)) $(eval save-vars-$o :=3D = )) >> + $(eval save-vars-$v :=3D ) >> + $(eval saved-vars-$v :=3D )) >> $(eval $2 :=3D $(value $2) $($2-new-value)) >> endef >> =20 >> --=20 >> 2.7.4 >> >>