This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
ar speed: sixfold improvement [PATCH]
- To: libc-hacker@cygnus.com
- Subject: ar speed: sixfold improvement [PATCH]
- From: Zack Weinberg <zack@rabi.phys.columbia.edu>
- Date: Thu, 30 Apr 1998 12:56:58 -0400
- Reply-To: libc-hacker@cygnus.com
Baseline time to reconstruct libc.a and libc.so on my machine
(rm libc* stamp.o* */stamp.o*; make lib):
206.29user 164.24system 29:07.97elapsed 21%CPU
(353955major+154079minor)pagefaults 241swaps
With the appended patch:
129.86user 24.09system 4:51.37elapsed 52%CPU
(56060major+71512minor)pagefaults 0swaps
That's a sixfold improvement in elapsed time and paging activity. I
get similar numbers for running make after changes in one or two
directories. Machine is a P133 with 32 megs memory.
When testing this patch I occasionally got a mangled libc_pic.a which
only contained the members that changed since the last build. I
think this bug has been eliminated but am not certain yet -- will
advise.
As a side effect, the 'ar S' hack goes away.
zw
Thu Apr 30 12:47:19 1998 Zack Weinberg <zack@rabi.phys.columbia.edu>
* Makerules (stamp.o): Just record the objects to be updated.
(libc.a(__.SYMDEF)): In addition to running ranlib, update the
objects in the archive using the names recorded in stamp files.
(CREATE_ARFLAGS): Kill the `ar S' hack.
* config.make.in: Delete have-ar-S.
* configure.in: Don't check for `ar S'. Instead, check whether
ranlib is necessary.
Index: Makerules
===================================================================
RCS file: /egcs/carton/cvsfiles/libc/Makerules,v
retrieving revision 1.288
diff -u -r1.288 Makerules
--- Makerules 1998/04/23 22:43:34 1.288
+++ Makerules 1998/04/30 16:36:45
@@ -510,11 +510,7 @@
endif # not -s
ARFLAGS := r$(verbose)
-ifeq ($(have-ar-S),yes)
-CREATE_ARFLAGS := Scru$(verbose)
-else
CREATE_ARFLAGS := cru$(verbose)
-endif
# This makes all the object files in the parent library archive.
@@ -557,14 +553,18 @@
object-suffixes-left := $(object-suffixes-for-libc)
include $(o-iterator)
-# The pattern rule tells Make to remake $(objpfx)stamp.% as
-# the way to update all the foo.% object files in $(objects). Now we
-# define explicit rules to update each $(objpfx)stamp.SUFFIX
-# timestamp file; these rules (one explicit rule is generated for each
-# object suffix) will update the parent archive with ar. Use a static
-# pattern rule so $* is set to the object type during the commands.
+# The pattern rule tells Make to remake $(objpfx)stamp.% as the way to
+# update all the foo.% object files in $(objects). Now we define
+# explicit rules to update each $(objpfx)stamp.SUFFIX timestamp file;
+# these rules (one explicit rule is generated for each object suffix)
+# write a list of objects to update in the stamp file. The parent
+# will then actually add them all to the archive in the ranlib rule,
+# below. Use a static pattern rule so $* is set to the object type
+# during the commands.
define o-iterator-doit
-$(objpfx)stamp$o: $(objpfx)stamp%: $(o-objects); $$(do-ar)
+$(objpfx)stamp$o: $(objpfx)stamp%: $(o-objects);
+ echo '$$(patsubst $$(common-objpfx)%,%,$$^)' > $$@T
+ mv -f $$@T $$@
endef
ifdef static-only-routines
object-suffixes-left := $(object-suffixes-for-libc)
@@ -572,15 +572,6 @@
object-suffixes-left := $(object-suffixes)
endif
include $(o-iterator)
-define do-ar
-topdir=`cd $(..). && pwd`; \
-$(patsubst %/,cd % &&,$(objpfx)) \
-$(SHELL) $$topdir/autolock.sh ${O%-lib}.lck $(AR) $(CREATE_ARFLAGS) ${O%-lib} \
- $(patsubst $(objpfx)%,%,$?)
-rm -f $@
-touch $@
-endef
-O%-lib = $(..)$(patsubst %,$(libtype$*),c)
ifndef static-only-routines
subdir_lib: $(objpfx)stamp.oS
@@ -592,14 +583,14 @@
endif
# Rules to update the $(ar-symtab-name) member with ranlib,
-# one for each object flavor.
+# one for each object flavor. (This also updates any changed objects.)
define o-iterator-doit
$(common-objpfx)$(patsubst %,$(libtype$o),c)($(ar-symtab-name)): \
- $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
- $(patsubst $(objpfx)%,%,$(o-objects))) $(subdirs-stamp-o); \
- $(SHELL) $$(..)./autolock.sh \
- $$(common-objpfx)$$(patsubst %,$$(libtype$o),c).lck \
- $$(RANLIB) $$(common-objpfx)$$(patsubst %,$$(libtype$o),c)
+ $(subdirs-stamp-o) $(common-objpfx)stamp$o;
+ cd $(common-objdir) \
+ && $(AR) $(CREATE_ARFLAGS) $$(@F)T \
+ `cat $$(patsubst $$(common-objpfx)%,%,$$^)` \
+ && $(RANLIB) $$(@F)T && mv -f $$(@F)T $$(@F)
endef
ifndef subdir
subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
Index: config.make.in
===================================================================
RCS file: /egcs/carton/cvsfiles/libc/config.make.in,v
retrieving revision 1.52
diff -u -r1.52 config.make.in
--- config.make.in 1998/04/21 17:58:51 1.52
+++ config.make.in 1998/04/30 16:36:45
@@ -35,7 +35,6 @@
versioning = @VERSIONING@
-have-ar-S=@libc_cv_ar_S@
have-no-whole-archive = @libc_cv_ld_no_whole_archive@
have-no-exceptions = @libc_cv_gcc_no_exceptions@
have-bash2 = @libc_cv_have_bash2@
Index: configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/libc/configure.in,v
retrieving revision 1.210
diff -u -r1.210 configure.in
--- configure.in 1998/04/21 17:59:02 1.210
+++ configure.in 1998/04/30 16:36:46
@@ -492,19 +492,26 @@
fi
AC_SUBST(SYSINCLUDES)
-# check if ar takes S
-AC_CACHE_CHECK(for ar S, libc_cv_ar_S, [dnl
-tmpo=$$.o
-tmplib=lib$$.a
-rm -f $tmpo $tmplib
-touch $tmpo
-if AC_TRY_COMMAND([${AR-ar} rcuS $tmplib $tmpo > /dev/null 2>&1]); then
- libc_cv_ar_S=yes
+# check if ranlib is necessary
+AC_CACHE_CHECK(whether ranlib is necessary, libc_cv_ranlib_necessary, [dnl
+cat > conftest.c <<EOF
+int a;
+char b;
+void c(void) {}
+EOF
+$CC $CFLAGS -c conftest.c
+$AR cr conftest.a conftest.c
+cp conftest.a conftest2.a
+$RANLIB conftest.a
+if cmp -s conftest.a conftest2.a; then
+ libc_cv_ranlib_necessary=no
else
- libc_cv_ar_S=no
+ libc_cv_ranlib_necessary=yes
fi
-rm -f $tmpo $tmplib])
-AC_SUBST(libc_cv_ar_S)dnl
+rm -rf conftest*])
+if test "$libc_cv_ranlib_necessary" = no; then
+ RANLIB=:
+fi
# Test if LD_LIBRARY_PATH contains the notation for the current directory
# since this would lead to problems installing/building glibc.