|
|
7760c3 |
http://sourceware.org/ml/gdb-patches/2014-10/msg00524.html
|
|
|
7760c3 |
Subject: [patch 1/2] Accelerate iter_match_first_hashed 1.8x
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
--17pEHd4RhPHOinZp
|
|
|
7760c3 |
Content-Type: text/plain; charset=us-ascii
|
|
|
7760c3 |
Content-Disposition: inline
|
|
|
7760c3 |
|
|
|
7760c3 |
Hi,
|
|
|
7760c3 |
|
|
|
7760c3 |
very simple caching. dict_hash() is being called again and again for the same
|
|
|
7760c3 |
string.
|
|
|
7760c3 |
|
|
|
7760c3 |
#0 in skip_spaces_const (chp=0x7fffb10f9bb6 "ts<char>, std::allocator<char> >::npos") at ./cli/cli-utils.c:244
|
|
|
7760c3 |
#1 in msymbol_hash_iw (string=0x7fffb10f9bb6 "ts<char>, std::allocator<char> >::npos") at minsyms.c:89
|
|
|
7760c3 |
#2 in dict_hash ( string0=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos") at dictionary.c:840
|
|
|
7760c3 |
#3 in iter_match_first_hashed (dict=0x105a7840, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", compare=0x8b82f8 <strcmp_iw>, iterator=0x7fffb10f9970) at dictionary.c:659
|
|
|
7760c3 |
#4 in dict_iter_match_first (dict=0x105a7840, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", compare=0x8b82f8 <strcmp_iw>, iterator=0x7fffb10f9970) at dictionary.c:555
|
|
|
7760c3 |
#5 in dict_iter_name_first (dict=0x105a7840, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", iterator=0x7fffb10f9970) at dictionary.c:541
|
|
|
7760c3 |
#6 in block_iter_name_step (iterator=0x7fffb10f9960, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", first=1) at block.c:580
|
|
|
7760c3 |
#7 in block_iter_name_first (block=0x10593e10, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", iterator=0x7fffb10f9960) at block.c:609
|
|
|
7760c3 |
#8 in lookup_block_symbol (block=0x10593e10, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", domain=VAR_DOMAIN) at symtab.c:2062
|
|
|
7760c3 |
#9 in lookup_symbol_aux_objfile (objfile=0x466f870, block_index=0, name=0x7fffb10f9b90 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos", domain=VAR_DOMAIN) at symtab.c:1664
|
|
|
7760c3 |
#10 in lookup_symbol_global_iterator_cb (objfile=0x466f870, cb_data=0x7fffb10f9ad0) at symtab.c:1868
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
Maybe it could get cached at the caller but:
|
|
|
7760c3 |
* We would need to pass the hash value along the whole {dict,block}_iter_*
|
|
|
7760c3 |
call chain.
|
|
|
7760c3 |
* The DICT_VECTOR virtualization would get violated as dict_linear*_vector do
|
|
|
7760c3 |
not use any hash values.
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
Jan
|
|
|
7760c3 |
|
|
|
7760c3 |
--17pEHd4RhPHOinZp
|
|
|
7760c3 |
Content-Type: text/plain; charset=us-ascii
|
|
|
7760c3 |
Content-Disposition: inline; filename="idxcache1.patch"
|
|
|
7760c3 |
|
|
|
7760c3 |
gdb/
|
|
|
7760c3 |
2014-10-20 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
7760c3 |
|
|
|
7760c3 |
* dictionary.c (iter_match_first_hashed): Provide state cache for
|
|
|
7760c3 |
hash_index from NAME.
|
|
|
7760c3 |
|
|
|
7760c3 |
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
|
|
|
7760c3 |
index 055c87e..90bcd6d 100644
|
|
|
7760c3 |
--- a/gdb/dictionary.c
|
|
|
7760c3 |
+++ b/gdb/dictionary.c
|
|
|
7760c3 |
@@ -656,9 +656,26 @@ iter_match_first_hashed (const struct dictionary *dict, const char *name,
|
|
|
7760c3 |
symbol_compare_ftype *compare,
|
|
|
7760c3 |
struct dict_iterator *iterator)
|
|
|
7760c3 |
{
|
|
|
7760c3 |
- unsigned int hash_index = dict_hash (name) % DICT_HASHED_NBUCKETS (dict);
|
|
|
7760c3 |
+ unsigned int hash_index;
|
|
|
7760c3 |
struct symbol *sym;
|
|
|
7760c3 |
|
|
|
7760c3 |
+ /* Cache HASH_INDEX. */
|
|
|
7760c3 |
+ {
|
|
|
7760c3 |
+ static const char *name_ptr_cached;
|
|
|
7760c3 |
+ static char *name_content_cached;
|
|
|
7760c3 |
+ static unsigned int dict_hash_cached;
|
|
|
7760c3 |
+
|
|
|
7760c3 |
+ if (name_ptr_cached != name || strcmp (name_content_cached, name) != 0)
|
|
|
7760c3 |
+ {
|
|
|
7760c3 |
+ dict_hash_cached = dict_hash (name);
|
|
|
7760c3 |
+ name_ptr_cached = name;
|
|
|
7760c3 |
+ xfree (name_content_cached);
|
|
|
7760c3 |
+ name_content_cached = xstrdup (name);
|
|
|
7760c3 |
+ }
|
|
|
7760c3 |
+ hash_index = dict_hash_cached;
|
|
|
7760c3 |
+ }
|
|
|
7760c3 |
+ hash_index %= DICT_HASHED_NBUCKETS (dict);
|
|
|
7760c3 |
+
|
|
|
7760c3 |
DICT_ITERATOR_DICT (iterator) = dict;
|
|
|
7760c3 |
|
|
|
7760c3 |
/* Loop through the symbols in the given bucket, breaking when SYM
|
|
|
7760c3 |
|
|
|
7760c3 |
--17pEHd4RhPHOinZp--
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
http://sourceware.org/ml/gdb-patches/2014-10/msg00612.html
|
|
|
7760c3 |
Subject: [patchv2 2/2] Accelerate lookup_symbol_aux_objfile 14.5x [Re: [patch 0/2] Accelerate symbol lookups 15x]
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
--vtzGhvizbBRQ85DL
|
|
|
7760c3 |
Content-Type: text/plain; charset=us-ascii
|
|
|
7760c3 |
Content-Disposition: inline
|
|
|
7760c3 |
|
|
|
7760c3 |
On Wed, 22 Oct 2014 10:55:18 +0200, Doug Evans wrote:
|
|
|
7760c3 |
> For example, the count of calls to dict_hash before/after goes from 13.8M to 31.
|
|
|
7760c3 |
> I'm guessing one t hing we're doing here is coping with an artifact of
|
|
|
7760c3 |
> dwz:
|
|
|
7760c3 |
|
|
|
7760c3 |
During my simple test on non-DWZ file (./gdb itself) it went 3684->3484.
|
|
|
7760c3 |
|
|
|
7760c3 |
The problem is that dict_cash(val) is called for the same val for each block
|
|
|
7760c3 |
(== symtab).
|
|
|
7760c3 |
|
|
|
7760c3 |
On DWZ the saving is probably much larger as there are many more symtabs due
|
|
|
7760c3 |
to DW_TAG_partial_unit ones.
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
> what was once one global block to represent the entire objfile is
|
|
|
7760c3 |
> now N.
|
|
|
7760c3 |
|
|
|
7760c3 |
Without DWZ there are X global blocks for X primary symtabs for X CUs of
|
|
|
7760c3 |
objfile. With DWZ there are X+Y global blocks for X+Y primary symtabs for
|
|
|
7760c3 |
X+Y CUs where Y are 'DW_TAG_partial_unit's.
|
|
|
7760c3 |
|
|
|
7760c3 |
For 'DW_TAG_partial_unit's (Ys) their blockvector is usually empty. But not
|
|
|
7760c3 |
always, I have found there typedef symbols, there can IMO be optimized-out
|
|
|
7760c3 |
static variables etc.
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
> [I'm sure the patches help in the non-dwz case, but I suspect it's less.
|
|
|
7760c3 |
> Which isn't to say the patches aren't useful.
|
|
|
7760c3 |
> I just need play with a few more examples.]
|
|
|
7760c3 |
|
|
|
7760c3 |
I agree.
|
|
|
7760c3 |
|
|
|
7760c3 |
[patch 2/2] could needlessly performance-regress non-DWZ cases, therefore
|
|
|
7760c3 |
I have put back original ALL_OBJFILE_PRIMARY_SYMTABS (instead of my
|
|
|
7760c3 |
ALL_OBJFILE_SYMTABS) as it is perfectly sufficient. For the performance
|
|
|
7760c3 |
testcase of mine:
|
|
|
7760c3 |
|
|
|
7760c3 |
Benchmark on non-trivial application with 'p <tab><tab>':
|
|
|
7760c3 |
Command execution time: 4.215000 (cpu), 4.241466 (wall) --- both fixes with new [patch 2/2]
|
|
|
7760c3 |
Command execution time: 7.373000 (cpu), 7.395095 (wall) --- both fixes
|
|
|
7760c3 |
Command execution time: 13.572000 (cpu), 13.592689 (wall) --- just lookup_symbol_aux_objfile fix
|
|
|
7760c3 |
Command execution time: 113.036000 (cpu), 113.067995 (wall) --- FSF GDB HEAD
|
|
|
7760c3 |
|
|
|
7760c3 |
That is additional 1.75x improvement, making the total improvement 26.8x.
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
No regressions on {x86_64,x86_64-m32,i686}-fedora21pre-linux-gnu in standard
|
|
|
7760c3 |
and .gdb_index-enabled runs. Neither of the patches should cause any visible
|
|
|
7760c3 |
behavior change.
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
Thanks,
|
|
|
7760c3 |
Jan
|
|
|
7760c3 |
|
|
|
7760c3 |
--vtzGhvizbBRQ85DL
|
|
|
7760c3 |
Content-Type: text/plain; charset=us-ascii
|
|
|
7760c3 |
Content-Disposition: inline; filename="idxcache2doug.patch"
|
|
|
7760c3 |
|
|
|
7760c3 |
gdb/
|
|
|
7760c3 |
2014-10-23 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
7760c3 |
|
|
|
7760c3 |
* symtab.c (lookup_symbol_aux_objfile): Use ALL_OBJFILE_SYMTABS, inline
|
|
|
7760c3 |
lookup_block_symbol.
|
|
|
7760c3 |
|
|
|
7760c3 |
diff --git a/gdb/symtab.c b/gdb/symtab.c
|
|
|
7760c3 |
index c530d50..da13861 100644
|
|
|
7760c3 |
--- a/gdb/symtab.c
|
|
|
7760c3 |
+++ b/gdb/symtab.c
|
|
|
7760c3 |
@@ -1657,15 +1657,25 @@ lookup_symbol_aux_objfile (struct objfile *objfile, int block_index,
|
|
|
7760c3 |
const struct block *block;
|
|
|
7760c3 |
struct symtab *s;
|
|
|
7760c3 |
|
|
|
7760c3 |
+ gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
|
|
|
7760c3 |
+
|
|
|
7760c3 |
ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
|
|
|
7760c3 |
{
|
|
|
7760c3 |
+ struct dict_iterator dict_iter;
|
|
|
7760c3 |
+
|
|
|
7760c3 |
bv = BLOCKVECTOR (s);
|
|
|
7760c3 |
block = BLOCKVECTOR_BLOCK (bv, block_index);
|
|
|
7760c3 |
- sym = lookup_block_symbol (block, name, domain);
|
|
|
7760c3 |
- if (sym)
|
|
|
7760c3 |
+
|
|
|
7760c3 |
+ for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
|
|
|
7760c3 |
+ sym != NULL;
|
|
|
7760c3 |
+ sym = dict_iter_name_next (name, &dict_iter))
|
|
|
7760c3 |
{
|
|
|
7760c3 |
- block_found = block;
|
|
|
7760c3 |
- return fixup_symbol_section (sym, objfile);
|
|
|
7760c3 |
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
|
|
|
7760c3 |
+ SYMBOL_DOMAIN (sym), domain))
|
|
|
7760c3 |
+ {
|
|
|
7760c3 |
+ block_found = block;
|
|
|
7760c3 |
+ return fixup_symbol_section (sym, objfile);
|
|
|
7760c3 |
+ }
|
|
|
7760c3 |
}
|
|
|
7760c3 |
}
|
|
|
7760c3 |
|
|
|
7760c3 |
|
|
|
7760c3 |
--vtzGhvizbBRQ85DL--
|
|
|
7760c3 |
|