public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/fw/dl-bind-performance] WIP mul64 dlsym optimization
@ 2022-04-11 14:07 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2022-04-11 14:07 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=060d8b9ced04715030eef33ce40ab64b34a0a349

commit 060d8b9ced04715030eef33ce40ab64b34a0a349
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Nov 11 16:09:32 2019 +0100

    WIP mul64 dlsym optimization
    
    Change-Id: I4caf4f14deb7a106c17e3ca89bdff5cd89f9541b

Diff:
---
 elf/dl-lookup.c | 18 ++++++++----------
 include/link.h  |  3 +--
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 205d043717..4d2f3b91f0 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -396,16 +396,15 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 				& (bitmask_word >> hashbit2) & 1))
 	    {
 	      Elf32_Word bucket;
-	      if (map->l_nbuckets > 1)
+	      if (powerof2 (map->l_nbuckets))
+		bucket = map->l_gnu_buckets[new_hash & (map->l_nbuckets - 1)];
+	      else
 		{
 		  uint32_t quotient
-		    = divopt_32 (new_hash, map->l_nbuckets_multiplier,
-				 map->l_nbuckets_multiplier_shift);
+		    = ((unsigned __int128) map->l_nbuckets_multiplier * ((uint64_t) new_hash + 1)) >> 64;
 		  uint32_t remainder = new_hash - map->l_nbuckets * quotient;
 		  bucket = map->l_gnu_buckets[remainder];
 		}
-	      else
-		bucket = map->l_gnu_buckets[0];
 
 	      if (bucket != 0)
 		{
@@ -942,11 +941,10 @@ _dl_setup_hash (struct link_map *map)
       /* Initialize MIPS xhash translation table.  */
       ELF_MACHINE_XHASH_SETUP (hash32, symbias, map);
 
-      if (map->l_nbuckets >= 2)
-	map->l_nbuckets_multiplier_shift
-	  = precompute_divopt_32 (map->l_nbuckets,
-				  &map->l_nbuckets_multiplier);
-
+      if (powerof2 (map->l_nbuckets))
+	map->l_nbuckets_multiplier = __builtin_ctz (map->l_nbuckets);
+      else
+	map->l_nbuckets_multiplier = ((unsigned __int128) 1 << 64) / map->l_nbuckets;
       return;
     }
 
diff --git a/include/link.h b/include/link.h
index b09aa81bb4..eec4c9ef6e 100644
--- a/include/link.h
+++ b/include/link.h
@@ -153,8 +153,7 @@ struct link_map
 
     /* Symbol hash table.  */
     Elf_Symndx l_nbuckets;
-    uint32_t l_nbuckets_multiplier;
-    int l_nbuckets_multiplier_shift;
+    uint64_t l_nbuckets_multiplier;
     Elf32_Word l_gnu_bitmask_idxbits;
     Elf32_Word l_gnu_shift;
     const ElfW(Addr) *l_gnu_bitmask;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-11 14:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 14:07 [glibc/fw/dl-bind-performance] WIP mul64 dlsym optimization Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).