From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1764 Path: news.gmane.org!not-for-mail From: musl Newsgroups: gmane.linux.lib.musl.general Subject: Re: ldso : dladdr support Date: Sun, 26 Aug 2012 00:37:17 +0200 Message-ID: <5039539D.7000806@gmail.com> References: <20120811230536.GQ27715@brightrain.aerifal.cx> <20120817053934.GS27715@brightrain.aerifal.cx> <50311776.9040802@gmail.com> <20120820020626.GD27715@brightrain.aerifal.cx> <503233A8.8000604@gmail.com> <50324A60.7040206@gmail.com> <20120823213937.GS27715@brightrain.aerifal.cx> <20120823222113.GT27715@brightrain.aerifal.cx> <50372D59.7090604@gmail.com> <20120824183850.GH27715@brightrain.aerifal.cx> <50394E26.6060707@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040104060203010006070602" X-Trace: ger.gmane.org 1345934255 19453 80.91.229.3 (25 Aug 2012 22:37:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Aug 2012 22:37:35 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1765-gllmg-musl=m.gmane.org@lists.openwall.com Sun Aug 26 00:37:36 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1T5Oz2-0000V0-1t for gllmg-musl@plane.gmane.org; Sun, 26 Aug 2012 00:37:36 +0200 Original-Received: (qmail 20193 invoked by uid 550); 25 Aug 2012 22:37:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20185 invoked from network); 25 Aug 2012 22:37:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=LlVAH2ZeMH2xcVMBJlkC4iAPiONpIh53UXzKJoqwUXs=; b=VTqiEhUgk9tND/GvjVGiSG/XN0FAgjBy90SNUzPmeI6c/S7ope7QxscsH65QVwwDXt qOk2gK4JpcFT1D6V5hRWgTdvNkgrRNwoVLAPoENysNbCppcW0cjKV/qHciNolK1fbggL cq6YJMBLEH7g73Oy8H2lMp3ugyKyWai7v04QXxoarcJrKpMpquaECVtQsfHrg49bfAhA SaYmLG7Nkm93VnZsWT+J6/TQQLQcNgvgm035tLgbQGVRtlsItSJU5zva+uCO3AAUWGCG eb5U/Nlr8EtKMHMY9/sB/erPlBAnKx6nYIhTvmNeRgUPNaspi8wXArOVW38zy6UysEXH Znow== User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: <50394E26.6060707@gmail.com> Xref: news.gmane.org gmane.linux.lib.musl.general:1764 Archived-At: This is a multi-part message in MIME format. --------------040104060203010006070602 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------040104060203010006070602 Content-Type: text/x-patch; name="gnuhash-bloom-filter.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gnuhash-bloom-filter.diff" 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; --------------040104060203010006070602--