From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18643 invoked by alias); 11 Feb 2008 22:10:43 -0000 Received: (qmail 18635 invoked by uid 22791); 11 Feb 2008 22:10:43 -0000 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO qnxmail.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 11 Feb 2008 22:10:19 +0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.42.96.5]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id QAA21621; Mon, 11 Feb 2008 16:55:42 -0500 Received: from [10.42.100.129] (dhcp-100-129 [10.42.100.129]) by smtp.ott.qnx.com (8.8.8/8.6.12) with ESMTP id RAA10427; Mon, 11 Feb 2008 17:10:16 -0500 Message-ID: <47B0C7C6.9090605@qnx.com> Date: Mon, 11 Feb 2008 22:10:00 -0000 From: Aleksandar Ristovski User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Daniel Jacobowitz CC: gdb-patches@sourceware.org Subject: Re: [patch] Do not add partial_symbol again and again to the list References: <47B0AEC7.3070400@qnx.com> <20080211203809.GA29560@caradoc.them.org> <47B0B56F.4010607@qnx.com> <20080211210935.GA31767@caradoc.them.org> <47B0C0F4.4090302@qnx.com> <20080211214750.GA1953@caradoc.them.org> In-Reply-To: <20080211214750.GA1953@caradoc.them.org> Content-Type: multipart/mixed; boundary="------------050303080709010201030708" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00189.txt.bz2 This is a multi-part message in MIME format. --------------050303080709010201030708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1692 Daniel Jacobowitz wrote: > On Mon, Feb 11, 2008 at 04:41:08PM -0500, Aleksandar Ristovski wrote: >> Daniel Jacobowitz wrote: >>> On Mon, Feb 11, 2008 at 03:51:59PM -0500, Aleksandar Ristovski wrote: >>>> Daniel Jacobowitz wrote: >>>>> On Mon, Feb 11, 2008 at 03:23:35PM -0500, Aleksandar Ristovski wrote: >>>>>> The attached patch checks if partial_symbol has already been added >>>>>> to the list instead of adding duplicate records. >>>>> How does this ever happen? It seems very wrong. Also, I am worried >>>>> that the linear search will be a bottleneck (this is quadratic as each >>>>> psymtab grows). >>>> Yes, I understand your concern about the complexity... but... >>> That's only part of the problem. You have this huge duplication of >>> identical partial symbols within the same block. How did that happen? >>> It shouldn't. Maybe we can avoid creating them in the first place. >>> >> Daniel, could you clarify: when you say "maybe we can avoid..." who is >> "we" - gdb or gcc? > > Probably GDB, but I don't know. Can you show me an example of these > unnecessary psymbols? > Some of them: unsigned int _GCC_ATTR_ALIGN_64t long long int _GCC_ATTR_ALIGN_u64t long long unsigned int _Int64t _Uint64t _GCC_ATTR_ALIGN_u32t unsigned int _GCC_ATTR_ALIGN_32t int _Uint32t _Int32t _GCC_ATTR_ALIGN_16t short int _GCC_ATTR_ALIGN_u16t short unsigned int _Int16t _Uint16t _GCC_ATTR_ALIGN_8t signed char _GCC_ATTR_ALIGN_u8t unsigned char _Int8t _Uint8t _Intptrt _Uintptrt _Longlong _ULonglong Additionally, please take a look at the modified patch, I have added bcache_added function to return whether it added the data or returned cached one. This way linear search is avoided. --------------050303080709010201030708 Content-Type: text/plain; name="bcache_added_donotduplicatepsyms.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bcache_added_donotduplicatepsyms.diff" Content-length: 4007 Index: gdb/bcache.h =================================================================== RCS file: /cvs/src/src/gdb/bcache.h,v retrieving revision 1.12 diff -u -p -r1.12 bcache.h --- gdb/bcache.h 1 Jan 2008 22:53:09 -0000 1.12 +++ gdb/bcache.h 11 Feb 2008 21:55:41 -0000 @@ -150,6 +150,8 @@ extern void *deprecated_bcache (const vo extern const void *bcache (const void *addr, int length, struct bcache *bcache); +extern void *bcache_added (const void *addr, int length, + struct bcache *bcache, int *added); /* Free all the storage used by BCACHE. */ extern void bcache_xfree (struct bcache *bcache); Index: gdb/bcache.c =================================================================== RCS file: /cvs/src/src/gdb/bcache.c,v retrieving revision 1.20 diff -u -p -r1.20 bcache.c --- gdb/bcache.c 1 Jan 2008 22:53:09 -0000 1.20 +++ gdb/bcache.c 11 Feb 2008 21:55:41 -0000 @@ -197,11 +197,34 @@ expand_hash_table (struct bcache *bcache static void * bcache_data (const void *addr, int length, struct bcache *bcache) { + return bcache_added (addr, length, bcache, NULL); +} + + +void * +deprecated_bcache (const void *addr, int length, struct bcache *bcache) +{ + return bcache_data (addr, length, bcache); +} + +const void * +bcache (const void *addr, int length, struct bcache *bcache) +{ + return bcache_data (addr, length, bcache); +} + +void * +bcache_added (const void *addr, int length, struct bcache *bcache, + int *added) +{ unsigned long full_hash; unsigned short half_hash; int hash_index; struct bstring *s; + if (added) + *added = 0; + /* If our average chain length is too high, expand the hash table. */ if (bcache->unique_count >= bcache->num_buckets * CHAIN_LENGTH_THRESHOLD) expand_hash_table (bcache); @@ -242,21 +265,12 @@ bcache_data (const void *addr, int lengt bcache->unique_size += length; bcache->structure_size += BSTRING_SIZE (length); + if (added) + *added = 1; + return &new->d.data; } } - -void * -deprecated_bcache (const void *addr, int length, struct bcache *bcache) -{ - return bcache_data (addr, length, bcache); -} - -const void * -bcache (const void *addr, int length, struct bcache *bcache) -{ - return bcache_data (addr, length, bcache); -} /* Allocating and freeing bcaches. */ Index: gdb/symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.198 diff -u -p -r1.198 symfile.c --- gdb/symfile.c 29 Jan 2008 22:47:20 -0000 1.198 +++ gdb/symfile.c 11 Feb 2008 21:55:46 -0000 @@ -3102,15 +3103,20 @@ add_psymbol_to_list (char *name, int nam enum language language, struct objfile *objfile) { struct partial_symbol *psym; - char *buf = alloca (namelength + 1); + int added; + char *buf = name; /* psymbol is static so that there will be no uninitialized gaps in the structure which might contain random data, causing cache misses in bcache. */ static struct partial_symbol psymbol; - - /* Create local copy of the partial symbol */ - memcpy (buf, name, namelength); - buf[namelength] = '\0'; + + if (name[namelength] != '\0') + { + buf = alloca (namelength + 1); + /* Create local copy of the partial symbol */ + memcpy (buf, name, namelength); + buf[namelength] = '\0'; + } /* val and coreaddr are mutually exclusive, one of them *will* be zero */ if (val != 0) { @@ -3128,8 +3134,11 @@ add_psymbol_to_list (char *name, int nam SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile); /* Stash the partial symbol away in the cache */ - psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol), - objfile->psymbol_cache); + psym = bcache_added (&psymbol, sizeof (struct partial_symbol), + objfile->psymbol_cache, &added); + + if (!added) + return psym; /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ if (list->next >= list->list + list->size) --------------050303080709010201030708--