[tz] [PROPOSED] Parallelize the main part of 'make to2050new.tzs'
Paul Eggert
eggert at cs.ucla.edu
Wed Feb 21 00:42:59 UTC 2018
This improves real-time performance of 'make -j4 to2050new.tzs' by
a factor of about 3.5 (from 120 s to 34 s) on my old 4-core desktop,
which runs Fedora 27 x86-64 atop an AMD Phenom II X4 910e.
* Makefile (ZDS): New macro.
($(ZDS)): New rule. All targets are phony.
($(TZS_NEW)): Use it in a submake that is parallelized by GNU make -j.
(check_links): Depend on tzdata.zi, fixing a dependency bug.
* NEWS: Mention this.
---
Makefile | 29 ++++++++++++++++++++---------
NEWS | 4 ++++
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index fc15c3e..835f34b 100644
--- a/Makefile
+++ b/Makefile
@@ -640,19 +640,29 @@ posix_packrat:
zones: $(REDO)
+# dummy.zd is not a real file; it is mentioned here only so that the
+# top-level 'make' does not have a syntax error.
+ZDS = dummy.zd
+# Rule used only by submakes invoked by the $(TZS_NEW) rule.
+# It is separate so that GNU 'make -j' can run instances in parallel.
+$(ZDS): zdump
+ ./zdump -i -c $(TZS_YEAR) '$(wd)/'$$(expr $@ : '\(.*\).zd') >$@
+
$(TZS_NEW): tzdata.zi zdump zic
- mkdir -p tzs.dir
+ rm -fr tzs.dir
+ mkdir tzs.dir
$(zic) -d tzs.dir tzdata.zi
$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
tzdata.zi | LC_ALL=C sort >$@.out
wd=`pwd` && \
- zones=`$(AWK) -v wd="$$wd" \
- '/^Z/{print wd "/tzs.dir/" $$2}' tzdata.zi \
- | LC_ALL=C sort` && \
- ./zdump -i -c $(TZS_YEAR) $$zones >>$@.out
- sed 's,^TZ=".*tzs\.dir/,TZ=",' $@.out >$@.sed.out
- rm -fr tzs.dir $@.out
- mv $@.sed.out $@
+ set x `$(AWK) '/^Z/{print "tzs.dir/" $$2 ".zd"}' tzdata.zi \
+ | LC_ALL=C sort -t . -k 2,2` && \
+ shift && \
+ ZDS=$$* && \
+ $(MAKE) wd="$$wd" TZS_YEAR=$(TZS_YEAR) ZDS="$$ZDS" $$ZDS && \
+ sed 's,^TZ=".*tzs\.dir/,TZ=",' $$ZDS >>$@.out
+ rm -fr tzs.dir
+ mv $@.out $@
# If $(TZS) does not already exist (e.g., old-format tarballs), create it.
# If it exists but 'make check_tzs' fails, a maintainer should inspect the
@@ -730,7 +740,7 @@ check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
LC_ALL=C sort -cu
-check_links: checklinks.awk $(TDATA_TO_CHECK)
+check_links: checklinks.awk $(TDATA_TO_CHECK) tzdata.zi
$(AWK) -f checklinks.awk $(TDATA_TO_CHECK)
$(AWK) -f checklinks.awk tzdata.zi
@@ -964,3 +974,4 @@ zic.o: private.h tzfile.h version.h
.PHONY: public right_only right_posix signatures signatures_version
.PHONY: tarballs tarballs_version typecheck
.PHONY: zonenames zones
+.PHONY: $(ZDS)
diff --git a/NEWS b/NEWS
index 3d18e89..1d2827e 100644
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,10 @@ Unreleased, experimental changes
already can use vanguard.zi; in this respect, current tzcode is
bleeding-edge.
+ The Makefile should now be safe for parallelized builds, and 'make
+ -j to2050new.tzs' is now much faster on a multiprocoessor host
+ with GNU Make.
+
When built with -DSUPPRESS_TZDIR, the tzcode library no longer
prepends TZDIR/ to file names that do not begin with '/'. This is
not recommended for general use, due to its security implications.
--
2.14.3
More information about the tz
mailing list