Subject: Reducing library searches in ld.elf_so
To: None <tech-userlevel@netbsd.org>
From: Bang Jun-Young <junyoung@mogua.com>
List: current-users
Date: 09/22/2002 23:46:05
Hi,

I have found that ld.elf_so does quite a number of ununcessary searches
on shared objects already loaded. Searches are quite expensive, so I
think it's one of the reasons why mozilla starts up so slowly. The
following patch fixes the problem, hopefully:


Index: search.c
===================================================================
RCS file: /cvsroot/basesrc/libexec/ld.elf_so/search.c,v
retrieving revision 1.10
diff -u -r1.10 search.c
--- search.c	2000/07/27 10:44:39	1.10
+++ search.c	2002/09/22 14:30:42
@@ -63,9 +63,16 @@
 _rtld_check_library(pathname)
 	const char *pathname;
 {
+	Obj_Entry *obj;
 	struct stat mystat;
 	Elf_Ehdr ehdr;
 	int fd;
+
+	for (obj = _rtld_objlist->next; obj != NULL; obj = obj->next)
+		if (strcmp(obj->path, pathname) == 0) {
+			dbg(("  %s is already on the list", pathname));
+			return true;
+		}
 
 	if (stat(pathname, &mystat) == -1 || !S_ISREG(mystat.st_mode))
 		return false;

For comparison, I have uploaded log files at my directory.

with current ld.elf_so:

	ftp://ftp.netbsd.org/pub/NetBSD/misc/junyoung/mozilla.log

with the patch applied:

	ftp://ftp.netbsd.org/pub/NetBSD/misc/junyoung/mozilla.log2

I'd like to hear if the patch is right and does really help reduce
loading time of mozilla binary.

Jun-Young

-- 
Bang Jun-Young <junyoung@mogua.com>