[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
HEAD: speed up compile mode
From: |
Ralf Wildenhues |
Subject: |
HEAD: speed up compile mode |
Date: |
Sun, 11 Feb 2007 15:59:40 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Separating out func_mode_link into a separate file shaves off roughly
30% of the script execution time of `libtool --mode=compile'. But
having yet another script hampers portability and simplicity. A nice
thing is that it's not necessary. It's sufficient to merely not to
have to parse the bulk of the script for this sort of speedup:
- Split up the main function to call func_mode_* right after the
function definition.
- Move all functions (including call) in weighted priority of both
expected usage number, average execution time per usage, and size.
IOW, func_mode_compile first, func_mode_link and all functions that
are only needed by it last.
Compared to branch-1-5, HEAD then needs less than half as long for
compile mode. Here's an example:
Compiling 100 objects of CLN with `libtool -n ... >/dev/null'. That is,
measuring script overhead only. The sources are C++, the --tag=CXX
argument is not passed so func_infer_tag has to do work.
branch-1-5:
10.18user 7.39system 0:17.54elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1737723minor)pagefaults 0swaps
HEAD:
8.84user 3.24system 0:12.29elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+740140minor)pagefaults 0swaps
HEAD with a separate libtool-link script:
5.55user 2.77system 0:08.32elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+686277minor)pagefaults 0swaps
HEAD with the Main split (patch below):
5.63user 2.71system 0:08.32elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+682353minor)pagefaults 0swaps
HEAD with patch below plus reordering of functions:
5.29user 2.91system 0:08.05elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+680683minor)pagefaults 0swaps
Interestingly, adding --tag=CXX slows down the build by 2%. Using the
C compiler instead of the C++ compiler (thus avoiding the need to search
for another tag) is 18% faster, where again passing --tag=CC slows down
things a bit. (But see the next patch.)
OK to apply? This set of patches is a helper for the 2.0 release in
that it helps test Libtool more efficiently. ;-)
Seriously though, if you see any problems with this, then we can
postpone them. They have seen quite some test exposure though, since I
wrote them some months ago. Anyway I'd want to postpone any moving of
functions until we use something better than CVS and viewcvs.
Note the shell function markers are not needed any more. They were
added by Peter on 2004-12-20 and went obsolete by the change by Peter
and Alexandre on 2005-04-17. I'm removing them, now that we'd need a
lot more of them.
Cheers,
Ralf
2007-02-11 Ralf Wildenhues <address@hidden>
Eliminate roughly a third of the script execution time overhead
for all modes except for link/relink and uninstall/clean.
* libltdl/m4/libtool.m4 (_LT_CONFIG): Remove unused `TEST SUITE
MARKER', obsolete since 2005-04-17.
* libltdl/config/ltmain.m4sh: Likewise, several instances.
(Main): Tear apart, moving individual bits up as early in the
script as possible, to help the shell to avoid parsing the rest.
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.59
diff -u -r1.59 ltmain.m4sh
--- libltdl/config/ltmain.m4sh 28 Jan 2007 15:13:25 -0000 1.59
+++ libltdl/config/ltmain.m4sh 11 Feb 2007 14:49:41 -0000
@@ -425,7 +425,6 @@
exit $?
}
-# TEST SUITE MARKER ## NON-FUNCTION
# Parse options once, thoroughly. This comes as soon as possible in
# the script to make things like `libtool --version' happen quickly.
{
@@ -576,7 +575,6 @@
# anything was wrong.
$exit_cmd $EXIT_FAILURE
}
-# TEST SUITE MARKER ## BEGIN SOURCABLE
# func_check_version_match
# Ensure that we are using m4 macros, and libtool script from the same
@@ -614,6 +612,38 @@
}
+## ----------- ##
+## Main. ##
+## ----------- ##
+
+{
+ # Sanity checks first:
+ func_check_version_match
+
+ if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ func_fatal_configuration "not configured to build any kind of library"
+ fi
+
+ test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+ # Darwin sucks
+ eval std_shrext=\"$shrext_cmds\"
+
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$execute_dlfiles" && test "$mode" != execute; then
+ func_error "unrecognized option \`-dlopen'"
+ $ECHO "$help" 1>&2
+ exit $EXIT_FAILURE
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
# func_lalib_p file
# True iff FILE is a libtool `.la' library or `.lo' object file.
# This function is only a basic sanity check; it will hardly flush out
@@ -1549,6 +1579,8 @@
exit $EXIT_SUCCESS
}
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+
# func_mode_execute arg...
func_mode_execute ()
@@ -1674,6 +1706,8 @@
fi
}
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
# func_mode_finish arg...
func_mode_finish ()
@@ -1752,6 +1786,8 @@
exit $EXIT_SUCCESS
}
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
# func_mode_install arg...
func_mode_install ()
@@ -2183,6 +2219,8 @@
fi
}
+test "$mode" = install && func_mode_install ${1+"$@"}
+
# func_mode_link arg...
func_mode_link ()
@@ -6710,6 +6748,9 @@
exit $EXIT_SUCCESS
}
+{ test "$mode" = link || test "$mode" = relink; } &&
+ func_mode_link ${1+"$@"}
+
# func_mode_uninstall arg...
func_mode_uninstall ()
@@ -6877,59 +6918,21 @@
exit $exit_status
}
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+ func_mode_uninstall ${1+"$@"}
-# TEST SUITE MARKER ## NON-FUNCTION
-## ----------- ##
-## Main. ##
-## ----------- ##
-
-{
- # Sanity checks first:
- func_check_version_match
-
- if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
- func_fatal_configuration "not configured to build any kind of library"
- fi
-
- test -z "$mode" && func_fatal_error "error: you must specify a MODE."
-
-
- # Darwin sucks
- eval std_shrext=\"$shrext_cmds\"
-
-
- # Only execute mode is allowed to have -dlopen flags.
- if test -n "$execute_dlfiles" && test "$mode" != execute; then
- func_error "unrecognized option \`-dlopen'"
- $ECHO "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Change the help message to a mode-specific one.
- generic_help="$help"
- help="Try \`$progname --help --mode=$mode' for more information."
-
- case $mode in
- compile) func_mode_compile ${1+"$@"} ;;
- execute) func_mode_execute ${1+"$@"} ;;
- finish) func_mode_finish ${1+"$@"} ;;
- install) func_mode_install ${1+"$@"} ;;
- link|relink) func_mode_link ${1+"$@"} ;;
- uninstall|clean) func_mode_uninstall ${1+"$@"} ;;
-
- "") help="$generic_help"
- func_fatal_help "you must specify a MODE"
- ;;
- esac
+test -z "$mode" && {
+ help="$generic_help"
+ func_fatal_help "you must specify a MODE"
+}
- test -z "$exec_cmd" && \
- func_fatal_help "invalid operation mode \`$mode'"
+test -z "$exec_cmd" && \
+ func_fatal_help "invalid operation mode \`$mode'"
- if test -n "$exec_cmd"; then
- eval exec "$exec_cmd"
- exit $EXIT_FAILURE
- fi
-}
+if test -n "$exec_cmd"; then
+ eval exec "$exec_cmd"
+ exit $EXIT_FAILURE
+fi
exit $exit_status
Index: libltdl/m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.90
diff -u -r1.90 libtool.m4
--- libltdl/m4/libtool.m4 5 Feb 2007 19:40:18 -0000 1.90
+++ libltdl/m4/libtool.m4 11 Feb 2007 14:49:44 -0000
@@ -674,7 +674,6 @@
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
#
_LT_COPYING
-# TEST SUITE MARKER ## BEGIN SOURCABLE
_LT_LIBTOOL_TAGS
# ### BEGIN LIBTOOL CONFIG
- HEAD: speed up compile mode,
Ralf Wildenhues <=