From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11686 invoked by alias); 15 Jan 2009 09:45:51 -0000 Received: (qmail 11677 invoked by uid 22791); 15 Jan 2009 09:45:51 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Jan 2009 09:45:15 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 48CCF290005 for ; Thu, 15 Jan 2009 10:45:12 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K-mDmyVqu25X for ; Thu, 15 Jan 2009 10:45:11 +0100 (CET) Received: from province.act-europe.fr (province.act-europe.fr [10.10.0.214]) by mel.act-europe.fr (Postfix) with ESMTP id 7A22B290002 for ; Thu, 15 Jan 2009 10:45:11 +0100 (CET) Received: by province.act-europe.fr (Postfix, from userid 560) id 54252165C5B; Thu, 15 Jan 2009 10:45:11 +0100 (CET) Date: Thu, 15 Jan 2009 09:45:00 -0000 From: Jerome Guitton To: gdb-patches@sources.redhat.com Subject: Re: [Bug symtab/8367] [RFA] performance improvement of lookup_partial_symtab Message-ID: <20090115094511.GB80710@adacore.com> References: <20090114174542.GM84382@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tjCHc7DPkfUGtrlw" Content-Disposition: inline In-Reply-To: <20090114174542.GM84382@adacore.com> User-Agent: Mutt/1.5.17 (2007-11-01) 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: 2009-01/txt/msg00345.txt.bz2 --tjCHc7DPkfUGtrlw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 354 Hmm, wrong MIME type for the attachment (video/dv?). Reposting it properly. Sorry for the noise. Jerome Guitton (guitton@adacore.com): > 2009-01-14 Jerome Guitton > > * symtab.c (lookup_partial_symtab): When looking up an absolute path > in the partial symtabs, compare the base names before checking the > full names. --tjCHc7DPkfUGtrlw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="lookup_partial_symtab.diff" Content-length: 2388 Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.200 diff -u -p -r1.200 symtab.c --- symtab.c 3 Jan 2009 05:57:53 -0000 1.200 +++ symtab.c 14 Jan 2009 17:10:27 -0000 @@ -281,8 +281,48 @@ lookup_partial_symtab (const char *name) } /* If the user gave us an absolute path, try to find the file in - this symtab and use its absolute path. */ - if (full_path != NULL) + this symtab and use its absolute path. + + psymtab_to_fullname has a significant cost as it calls + find_and_open_source, which itself does some I/O operation + (e.g. open). In cumulative, it can take several seconds with + large systems (around 4000 files), if the file is accessed + through a slow file system (e.g. NFS). Here is a shell script + that you can use to generate such a large system: + + echo "void main () {}" > t.c + gcc -c -g t.c + previous="" + for i in 0 1 2 3 ; do + for j in 0 1 2 3 4 5 6 7 8 9 ; do + for k in 0 1 2 3 4 5 6 7 8 9 ; do + for l in 0 1 2 3 4 5 6 7 8 9 ; do + name="${i}${j}${k}${l}" + echo "void f_$name () {}" >> f_$name.c + gcc -c -g f_$name.c + ld -r f_$name.o $previous -o main_$name + rm f_*.o + rm $previous + previous=main_$name + done + done + done + done + gcc $previous t.o -o main + + Using the following GDB commands should demonstrate the problem: + list /f_0000.c:1 + list /f_3999.c:1 + + To reduce the cost, the full comparison is done if and only if + the base names are not different. This would have a low cost, + as it only does string manipulations. This optimisation has no + impact on relatives path (e.g. the more common 'list + f_0000.c:1'), as in this case full_path == NULL. */ + + if (full_path != NULL + && FILENAME_CMP (lbasename (full_path), + lbasename (pst->filename)) == 0) { psymtab_to_fullname (pst); if (pst->fullname != NULL @@ -292,7 +332,9 @@ lookup_partial_symtab (const char *name) } } - if (real_path != NULL) + if (real_path != NULL + && FILENAME_CMP (lbasename (full_path), + lbasename (pst->filename)) == 0) { char *rp = NULL; psymtab_to_fullname (pst); --tjCHc7DPkfUGtrlw--