[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
optimize lt_combine
From: |
Eric Blake |
Subject: |
optimize lt_combine |
Date: |
Wed, 14 May 2008 21:04:41 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Revisiting an old thread:
http://lists.gnu.org/archive/html/libtool-patches/2007-10/msg00016.html
Here's an optimization to lt_combine, as well as its current clients to match
the slight semantic changes. If we ever start requiring autoconf 2.62, we can
then s/lt_combine/m4_combine/ without impact. I've updated the patch with the
conceptual m4sugar improvements that have been made in the meantime, while
still avoiding m4sugar constructs that were not available prior to 2.62.
Some statistics:
pre-patch:
$ rm -Rf autom4te.cache
$ autoconf --trace lt_combine | wc
3 3 1715
$ time autoconf --trace m4_shift | wc
23859 289406 20200516
real 1m18.914s
user 1m16.929s
sys 0m1.168s
$ wc autom4te.cache/traces.0
81870 1123343 23163745 autom4te.cache/traces.0
post-patch:
$ rm -Rf autom4te.cache
$ time autoconf --trace m4_shift | wc
20974 281283 16654686
real 1m3.968s
user 1m2.462s
sys 0m1.288s
$ wc autom4te.cache/traces.0
79178 948394 19087599 autom4te.cache/traces.0
Tracing m4_shift is inherently slow (mostly I/O time in generating the trace
file), since it is used so heavily ;) But these numbers show that autoconf
expands roughly 3000 fewer m4_shift calls (not to mention other macros that
weren't traced), and shaves off more than 4 megabytes of parsing with m4 1.4.x
(it is not until m4 1.6 that shift is optimized to avoid reparsing everything),
just by optimizing the three lt_combine calls that occur during libtool's
configure.ac (not to mention the subdirectories that also run autoconf during
bootstrap time).
The patch was previously deferred because 2.2 was "so close" to release; now
that it is out, is this okay to apply?
>From 9bdee069949f55656d0c8bf47914ea809e498592 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 16 Apr 2008 14:48:47 -0600
Subject: [PATCH] Speed up bootstrap by improving lt_combine.
* libltdl/m4/ltsugar.m4 (lt_combine): Mirror Autoconf 2.62
improvements. Includes a semantic change where the separator can
now be empty, and where an empty fourth argument is now treated as
a valid suffix.
* libltdl/m4/libtool.m4 (_lt_decl_varnames_tagged): Adjust to new
semantics of lt_combine.
(lt_decl_varnames_tagged): Fix quoting and optimize.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 11 +++++++++++
libltdl/m4/libtool.m4 | 12 ++++++------
libltdl/m4/ltsugar.m4 | 22 +++++++++++-----------
3 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e556e7c..58ebb19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-05-14 Eric Blake <address@hidden>
+
+ Speed up bootstrap by improving lt_combine.
+ * libltdl/m4/ltsugar.m4 (lt_combine): Mirror Autoconf 2.62
+ improvements. Includes a semantic change where the separator can
+ now be empty, and where an empty fourth argument is now treated as
+ a valid suffix.
+ * libltdl/m4/libtool.m4 (_lt_decl_varnames_tagged): Adjust to new
+ semantics of lt_combine.
+ (lt_decl_varnames_tagged): Fix quoting and optimize.
+
2008-05-13 Eric Blake <address@hidden>
Kill _LT_LIBSOURCES; it wasn't checking anything useful.
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 4d31e80..1144395 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -380,12 +380,12 @@ m4_define([lt_decl_dquote_varnames],
# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
# ---------------------------------------------------
m4_define([lt_decl_varnames_tagged],
-[_$0(m4_quote(m4_default([$1], [[, ]])),
- m4_quote(m4_if([$2], [],
- m4_quote(lt_decl_tag_varnames),
- m4_quote(m4_shift($@)))),
- m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
-m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+ m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
diff --git a/libltdl/m4/ltsugar.m4 b/libltdl/m4/ltsugar.m4
index 0d258e0..3e576d5 100644
--- a/libltdl/m4/ltsugar.m4
+++ b/libltdl/m4/ltsugar.m4
@@ -1,13 +1,13 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
-# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
-# Written by Gary V. Vaughan, 2004
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
-# serial 5 ltsugar.m4
+# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
@@ -63,14 +63,14 @@ m4_define([lt_append],
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
-[m4_if([$2], [], [],
- [m4_if([$4], [], [],
- [lt_join(m4_quote(m4_default([$1], [[, ]])),
- lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2],
- [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]),
- [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl
-])
+[m4_if(m4_eval([$# > 3]), [1],
+ [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+ [m4_foreach([_Lt_suffix],
+ ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+ [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
--
1.5.5.1
- optimize lt_combine,
Eric Blake <=