Subject: bin/25464: major performance improvement for ld.elf_so for netbsd-1-6 (esp. alpha)
To: None <>
From: Greg A. Woods <>
List: netbsd-bugs
Date: 05/04/2004 17:40:03
>Number:         25464
>Category:       bin
>Synopsis:       major performance improvement for ld.elf_so for netbsd-1-6 (esp. alpha)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue May 04 21:41:01 UTC 2004
>Originator:     Greg A. Woods
>Release:        NetBSD 1.6.2
Planix, Inc.; Toronto, Ontario; Canada
System: NetBSD 1.6.2
Architecture: alpha,i386
Machine: alpha,i386

	The ld.elf_so in 1.6.2 causes severe performance degradation for
	some applications with dynamic-loaded object code, such as
	Mozilla, especially on alpha where such applications are all but
	unusable even on fast machines.  However this problem has been
	fixed in -current.


	try running, for example, mozilla-1.6 on an alpha running 1.6.2


	Jason suggested I send a complete diff, but it's exceedingly
	large.  The following instructions implement the necessary
	pullups direct from CVS, with only minor fixups necessary.  The
	results have been tested on alpha and i386, including with a
	full build on the alpha.  For such a behemoth mozilla-gtk2 (1.6)
	is now quite snappy and responsive on my as4000 (@500MHz).  (it
	is even much faster than MozillaFirebird (1.5) on a 300MHz PII,
	but that's hardly a good comparison).

- first get the right revs from approx 2003/04/21, i.e. before the
  ansification and most other non-performance related recent changes:

	cd /usr/src/libexec
	cvs co -P -D 2003/04/21 -d ld.elf_so-20030421 src/libexec/ld.elf_so
	cd ld.elf_so-20030421
	find . -type f ! -name '.#*' -print -o -name CVS -prune | pax -rw ../ld.elf_so
	cd ..
	cvs release -d ld.elf_so-20030421

- fix up the Makefile with this patch:

--- Makefile-20030421	Tue Mar 25 08:11:53 2003
+++ Makefile	Sun May  2 18:38:04 2004
@@ -1,7 +1,6 @@
 #	$NetBSD: Makefile,v 1.61 2003/03/25 13:11:53 scw Exp $
 .include <>			# for OBJECT_FMT definition
-.include <>			# for SHLINKINSTALLDIR definition
@@ -34,7 +33,11 @@
 SRCS+=	rtld.c reloc.c symbol.c malloc.c xmalloc.c xprintf.c debug.c \
 	map_object.c load.c search.c headers.c paths.c
+# make sure we don't trash the current one!
@@ -63,8 +66,8 @@
 ${PROG}: ${OBJS} ${DPADD}
 	${LD} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
-.if ${SHLINKINSTALLDIR} != "/usr/libexec"
+.if ${SHLINKDIR} != "/usr/libexec"
+SYMLINKS+=	${SHLINKDIR}/${PROG} /usr/libexec/${PROG}
 .include <>

- next revert lukem's SIMPLEQ_* changes (cvs diff -D 2002/05/31 -D 2002/06/02 .):

	cvs diff -kk -r 1.12 -r 1.13 map_object.c | patch -R map_object.c
	cvs diff -kk -r 1.49 -r 1.50 rtld.c | patch -R rtld.c
	cvs diff -kk -r 1.15 -r 1.16 load.c | patch -R load.c
	cvs diff -kk -r 1.11 -r 1.12 symbol.c | patch -R symbol.c

  the last patch will not apply cleanly so take the line 84 change from
  symbol.c.rej and apply it to line 91 of the resulting symbol.c file

- pull in the setproctitle() fix for alpha:

	cvs diff -kk -u -r 1.15 -r 1.16 arch/alpha/rtld_start.S | patch arch/alpha/rtld_start.S

- finally since ldd.c uses code from ld.elf_so, update it as well:

	cd /usr/src/usr.bin/ldd/ldd_elf
	cvs update -r 1.19 -p ldd.c > ldd.c