Subject: Re: reducing library searches in ld.elf_so
To: Charles Hannum <abuse@spamalicious.com>
From: Bang Jun-Young <junyoung@mogua.com>
List: tech-userlevel
Date: 09/23/2002 14:12:02
On Sun, Sep 22, 2002 at 07:34:25PM +0000, Charles Hannum wrote:
>
> While your patch may help a little, I do not think it's sufficient
> even to fully mitigate the problem you're talking about. The problem
> is that it only affects lookup hits, not misses, and so a certain
> number of missed lookups will occur in many (most?) cases anyway.
>
> Perhaps better would be to hook into:
>
> for (sp = _rtld_paths; sp != NULL; sp = sp->sp_next)
> if ((pathname = _rtld_search_library_path(name, namelen,
> sp->sp_path, sp->sp_pathlen)) != NULL)
> return (pathname);
>
> (and the _rtld_default_paths case below it), and to record both
> positive and negative hits here by file name (without the path). This
> would allow us to do a simple table lookup the next time we see the
> file name.
That would require us to maintain file name list aside from path list,
wouldn't it?
BTW, I had a look at it again and moved the code into
_rtld_search_library_path() so that I could save calls to
_rtld_check_library() in many cases (with mozilla, the number is 418).
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/23 04:32:23
@@ -110,11 +110,18 @@
size_t dirlen;
{
char *pathname;
+ Obj_Entry *obj;
pathname = xmalloc(dirlen + 1 + namelen + 1);
(void)strncpy(pathname, dir, dirlen);
pathname[dirlen] = '/';
strcpy(pathname + dirlen + 1, name);
+
+ 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 pathname;
+ }
dbg((" Trying \"%s\"", pathname));
if (_rtld_check_library(pathname)) /* We found it */
If there's no better solution, I'll commit it in a few days.
Jun-Young
--
Bang Jun-Young <junyoung@mogua.com>