Bug 14125 - Performance issue with .gdb_index and large numbers of shared libs
Summary: Performance issue with .gdb_index and large numbers of shared libs
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: dje
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-20 14:49 UTC by dje
Modified: 2012-06-23 22:27 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dje 2012-05-20 14:49:54 UTC
When .gdb_index is in use there isn't a bit that specifies GLOBAL_BLOCK vs STATIC_BLOCK, so if something is in STATIC_BLOCK (say "int") it matches so gdb will expand the symbol table, but the match doesn't take into account the block kind. So gdb will proceed to expand one symbol table from every objfile looking for "int" in GLOBAL_BLOCK, finding it, but not using it.
Only after that is done will GDB try STATIC_BLOCK.
In a large enough app (e.g., >1000 shared libs) this is painful.
Comment 1 dje 2012-05-20 14:57:41 UTC
For this my plan is to indicate in the index whether a symbol is in GLOBAL_BLOCK or STATIC_BLOCK.

Another thing that I've been wondering about is adding an indication of whether a symbol is a type, function, variable, etc.  IIRC there's a performance issue where that would help (I need to try to find it - IWBN to only change the index format once).
Comment 2 dje 2012-05-21 01:19:57 UTC
Hmmm,

write_psymbols:

      /* We only want to add a given psymbol once.  However, we also                                                                                             
         want to account for whether it is global or static.  So, we                                                                                             
         may add it twice, using slightly different values.  */
      if (is_static)
        {
          uintptr_t val = 1 | (uintptr_t) *psymp;

          lookup = (void *) val;
        }
      else
        lookup = *psymp;
Comment 3 cvs-commit@gcc.gnu.org 2012-06-23 22:23:53 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	devans@sourceware.org	2012-06-23 22:23:48

Modified files:
	gdb            : ChangeLog NEWS dwarf2read.c 
	gdb/doc        : ChangeLog gdb.texinfo 

Log message:
	PR 14125
	* NEWS: Document additions to .gdb_index.
	* dwarf2read.c: #include "gdb/gdb-index.h".
	(DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE): New macro.
	(DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE): New macro.
	(DW2_GDB_INDEX_CU_SET_VALUE): New macro.
	(dwarf2_read_index): Recognize version 7.
	(dw2_do_expand_symtabs_matching): New args want_specific_block,
	block_kind, domain): All callers updated.
	(dw2_find_symbol_file): Handle new index CU values.
	(dw2_expand_symtabs_matching): Match symbol kind if requested.
	(add_index_entry): New args is_static, kind.  All callers updated.
	(offset_type_compare, uniquify_cu_indices): New functions
	(symbol_kind): New function.
	(write_psymtabs_to_index): Remove duplicate CU values.
	(write_psymtabs_to_index): Write .gdb_index version 7.
	
	doc/
	* gdb.texinfo (Index Section Format): Document version 7 format.
	
	include/gdb/
	* gdb-index.h: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14390&r2=1.14391
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/NEWS.diff?cvsroot=src&r1=1.527&r2=1.528
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.665&r2=1.666
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.1333&r2=1.1334
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.978&r2=1.979
Comment 4 dje 2012-06-23 22:27:05 UTC
Patch committed.