mailing list of musl libc
 help / color / mirror / code / Atom feed
From: musl <b.brezillon.musl@gmail.com>
To: musl@lists.openwall.com
Subject: Re: ldso : dladdr support
Date: Sun, 26 Aug 2012 00:37:17 +0200	[thread overview]
Message-ID: <5039539D.7000806@gmail.com> (raw)
In-Reply-To: <50394E26.6060707@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]

On 26/08/2012 00:13, musl wrote:
> On 24/08/2012 20:38, Rich Felker wrote:
>> On Fri, Aug 24, 2012 at 09:29:29AM +0200, musl wrote:
>>> I tested it and it works well.
>> Is there anything I changed that you think might be better done a
>> different way?
>>
>>> My tests are based on small libs (with a small set of shared symbols).
>>> I mixed libs with gnu hash and sysv hash.
>>> Tried to resolve symbols via dlsym.
>>>
>>> Have you tested it on big libraries ?
>> No, just very minimal testing.
>>
>>> Do you want me to do some specific tests ?
>> Actually, the main thing I'm interested in is whether the bloom filter
>> is ever beneficial. I took it out trying to streamline the code and
>> shaved about 8% off the lookup time for symbols in the main program,
>> but I didn't investigate how the change affects symbols not found in
>> the first file searched. Would you be interested in running some tests
>> to determine if it might be useful to try adding it back?
>>
>> Since it seems to be working/non-broken right now, I'll probably go
>> ahead and commit soon unless you find a major problem I've overlooked.
>> Then we can work on improving it once it's in the repo.
> I executed your test program (gnuhash) with and without bloom filter test, and I get pretty much the same results in
> both cases if the symbol is defined.
> What compiler option did you use to compile gnuhash.c ?
>
> I also tried to search for a missing symbol and the version with bloom filter is 3% faster.
>
> I'll do more tests with bigger libs and different linker optimizations (some linker optims change the number of buckets
> in the hash table => less entries per hash chains => faster search in case there's no valid entry for a given name).
>
>  
Here is the patch I used to add bloom filter test.
>
>  
>> Rich


[-- Attachment #2: gnuhash-bloom-filter.diff --]
[-- Type: text/x-patch, Size: 958 bytes --]

diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index c733dc5..a4b150c 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -138,6 +138,7 @@ static Sym *sysv_lookup(const char *s, uint32_t h, struct dso *dso)
 	return 0;
 }
 
+#define BWSZ (sizeof(size_t)*8)
 static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso)
 {
 	Sym *sym;
@@ -145,10 +146,15 @@ static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso)
 	uint32_t *hashtab = dso->ghashtab;
 	uint32_t nbuckets = hashtab[0];
 	uint32_t *buckets = hashtab + 4 + hashtab[2]*(sizeof(size_t)/4);
-	uint32_t h2;
+	size_t *maskwords = (size_t *)(hashtab + 4);
+	uint32_t h2 = h1 >> hashtab[3];
 	uint32_t *hashval;
-	uint32_t n = buckets[h1 % nbuckets];
+	uint32_t n = (h1/BWSZ) & (hashtab[2]-1);
+	size_t bm = (1 << (h1%BWSZ)) | (1 << (h2%BWSZ));
 
+	if ((maskwords[n] & bm) != bm) return 0;
+
+	n = buckets[h1 % nbuckets];
 	if (!n) return 0;
 
 	strings = dso->strings;

  reply	other threads:[~2012-08-25 22:37 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07  9:04 musl
2012-08-07 11:46 ` Szabolcs Nagy
2012-08-07 14:15   ` musl
2012-08-07 14:53     ` Szabolcs Nagy
2012-08-07 23:09     ` Rich Felker
2012-08-08  9:55       ` musl
2012-08-08 11:52         ` Szabolcs Nagy
2012-08-08 12:54           ` Rich Felker
2012-08-08 13:57           ` musl
2012-08-11 23:05             ` Rich Felker
2012-08-15 22:41               ` boris brezillon
2012-08-17  5:39                 ` Rich Felker
2012-08-19 16:42                   ` musl
2012-08-20  2:06                     ` Rich Felker
2012-08-20 12:55                       ` musl
2012-08-20 14:32                         ` musl
2012-08-23 21:39                           ` Rich Felker
2012-08-23 22:21                             ` Rich Felker
2012-08-24  7:29                               ` musl
2012-08-24 18:38                                 ` Rich Felker
2012-08-25  7:42                                   ` boris brezillon
2012-08-25 12:35                                     ` Rich Felker
2012-08-25 22:13                                   ` musl
2012-08-25 22:37                                     ` musl [this message]
2012-08-26  0:00                                   ` musl
2012-08-24  8:12                               ` Szabolcs Nagy
2012-08-24  8:56                                 ` musl
2012-08-24  9:38                                   ` Szabolcs Nagy
2012-08-25 21:34                               ` musl
2012-08-25 21:42                                 ` Rich Felker
2012-08-16 18:03               ` musl
2012-08-17 16:35               ` musl
2012-08-08 12:49         ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5039539D.7000806@gmail.com \
    --to=b.brezillon.musl@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).