[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/25] rules.mak: speedup save-vars load-vars
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 06/25] rules.mak: speedup save-vars load-vars |
Date: |
Thu, 22 Dec 2016 16:22:41 +0100 |
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).
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
rules.mak | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/rules.mak b/rules.mak
index f4839d2..c69863f 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 contains the variables that
+# where saved for the objects, in order to speedup load-vars.
define save-vars
$(foreach v,$1,
$(eval save-vars-$v := $(value $v))
- $(foreach o,$($v),
- $(foreach k,cflags libs objs,
- $(if $($o-$k),
- $(eval save-vars-$o-$k := $($o-$k))
- $(eval $o-$k := ))))
+ $(eval saved-vars-$v := $(foreach o,$($v), \
+ $(if $($o-cflags), $o-cflags $(eval save-vars-$o-cflags :=
$($o-cflags))$(eval $o-cflags := )) \
+ $(if $($o-libs), $o-libs $(eval save-vars-$o-libs :=
$($o-libs))$(eval $o-libs := )) \
+ $(if $($o-objs), $o-objs $(eval save-vars-$o-objs :=
$($o-objs))$(eval $o-objs := ))))
$(eval $v := ))
endef
@@ -213,12 +213,10 @@ define load-vars
$(eval $2-new-value := $(value $2))
$(foreach v,$1,
$(eval $v := $(value save-vars-$v))
- $(foreach o,$($v),
- $(foreach k,cflags libs objs,
- $(if $(save-vars-$o-$k),
- $(eval $o-$k := $(save-vars-$o-$k))
- $(eval save-vars-$o-$k := ))))
- $(eval save-vars-$v := ))
+ $(foreach o,$(saved-vars-$v),
+ $(eval $o := $(save-vars-$o)) $(eval save-vars-$o := ))
+ $(eval save-vars-$v := )
+ $(eval saved-vars-$v := ))
$(eval $2 := $(value $2) $($2-new-value))
endef
--
2.9.3
- [Qemu-devel] [PULL 00/25] First round of misc patches for QEMU 2.9, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 01/25] exec: optimize remaining address_space_* cases, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 04/25] exec: introduce MemoryRegionCache, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 02/25] exec: introduce memory_ldst.inc.c, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 03/25] exec: introduce address_space_extend_translation, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 05/25] watchdog: 6300esb: add exit function, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 07/25] rules.mak: add more rules to avoid chaining, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 08/25] build-sys: remove libtool left-over, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 06/25] rules.mak: speedup save-vars load-vars,
Paolo Bonzini <=
- [Qemu-devel] [PULL 09/25] virtio-scsi: introduce virtio_scsi_acquire/release, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 10/25] qemu-timer: check active_timers outside lock/event, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 11/25] timer: fix misleading comment in timer.h, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 12/25] main-loop: update comment for qemu_mutex_lock/unlock_iothread, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 13/25] block: drop remaining legacy aio functions in comment, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 15/25] pc: make smbus configurable, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 17/25] pc: make pit configurable, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 14/25] target-i386: Add Intel SHA_NI instruction support., Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 16/25] pc: make sata configurable, Paolo Bonzini, 2016/12/22
- [Qemu-devel] [PULL 19/25] multiboot: copy the cmdline verbatim, unescape module strings, Paolo Bonzini, 2016/12/22