public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Doug Evans <xdje42@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [patchv3 2/2] Accelerate lookup_symbol_aux_objfile 85x
Date: Sat, 29 Nov 2014 12:11:00 -0000	[thread overview]
Message-ID: <20141129121124.GA21606@host2.jankratochvil.net> (raw)
In-Reply-To: <CAP9bCMTrzU7srWLfiS2814nfBEySJ-i6yKy7AKHBvXbUoLa-rQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 858 bytes --]

On Fri, 24 Oct 2014 09:16:01 +0200, Doug Evans wrote:
> This breaks an abstraction boundary, IWBN to preserve it.
> [IOW, I look at dict_* as being an implementation detail of blocks.]
> 
> If we were to go this route (and apologies for the delay), can you
> write a routine like lookup_block_symbol which does the above and call
> that here instead?
> 
> lookup_block_symbol should live in block.c, not symtab.c.
> That's where this new routine should go too.

Done.

For the 'slow.C' test the performance gain is even higher; but I have not
re-benchmarked the 'non-trivial app':
	Command execution time: 26.540344 (cpu), 26.575254 (wall)
	->
	Command execution time: 0.310607 (cpu), 0.311062 (wall)
	 = 85x

OK for check-in?

No regressions on {x86_64,x86_64-m32,i686}-fedora21-linux-gnu native and in
DWZ and in -fdebug-types-section modes.


Thanks,
Jan

[-- Attachment #2: idx2.patch --]
[-- Type: text/plain, Size: 2806 bytes --]

gdb/
2014-11-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* block.c (block_lookup_symbol_primary): New function.
	* block.h (block_lookup_symbol_primary): New declaration.
	* symtab.c (lookup_symbol_in_objfile_symtabs): Assert BLOCK_INDEX.
	Call block_lookup_symbol_primary.

diff --git a/gdb/block.c b/gdb/block.c
index 597d143..e791c73 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -746,3 +746,28 @@ block_lookup_symbol (const struct block *block, const char *name,
       return (sym_found);	/* Will be NULL if not found.  */
     }
 }
+
+/* See block.h.  */
+
+struct symbol *
+block_lookup_symbol_primary (const struct block *block, const char *name,
+			     const domain_enum domain)
+{
+  struct symbol *sym;
+  struct dict_iterator dict_iter;
+
+  /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK.  */
+  gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
+	      || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
+
+  for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
+       sym != NULL;
+       sym = dict_iter_name_next (name, &dict_iter))
+    {
+      if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+				 SYMBOL_DOMAIN (sym), domain))
+	return sym;
+    }
+
+  return NULL;
+}
diff --git a/gdb/block.h b/gdb/block.h
index bd358d6..409a5c7 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -276,6 +276,14 @@ extern struct symbol *block_lookup_symbol (const struct block *block,
 					   const char *name,
 					   const domain_enum domain);
 
+/* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of
+   BLOCK.  BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK.  Function is useful if
+   one iterates all global/static blocks of an objfile.  */
+
+extern struct symbol *block_lookup_symbol_primary (const struct block *block,
+						   const char *name,
+						   const domain_enum domain);
+
 /* Macro to loop through all symbols in BLOCK, in no particular
    order.  ITER helps keep track of the iteration, and must be a
    struct block_iterator.  SYM points to the current symbol.  */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 345c20d..fd93fb8 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1618,6 +1618,8 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
 {
   struct compunit_symtab *cust;
 
+  gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
+
   ALL_OBJFILE_COMPUNITS (objfile, cust)
     {
       const struct blockvector *bv;
@@ -1626,7 +1628,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
 
       bv = COMPUNIT_BLOCKVECTOR (cust);
       block = BLOCKVECTOR_BLOCK (bv, block_index);
-      sym = block_lookup_symbol (block, name, domain);
+      sym = block_lookup_symbol_primary (block, name, domain);
       if (sym)
 	{
 	  block_found = block;

  parent reply	other threads:[~2014-11-29 12:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 21:44 [patch 0/2] Accelerate symbol lookups 15x Jan Kratochvil
2014-10-22  8:55 ` Doug Evans
2014-10-23 18:24   ` [patchv2 2/2] Accelerate lookup_symbol_aux_objfile 14.5x [Re: [patch 0/2] Accelerate symbol lookups 15x] Jan Kratochvil
2014-10-24  7:16     ` Doug Evans
2014-10-24  7:33       ` Jan Kratochvil
2014-10-24 16:07         ` Doug Evans
2014-10-27  5:55           ` Doug Evans
2014-10-27  6:02             ` Doug Evans
2014-10-27  8:54             ` Jan Kratochvil
2014-11-29 12:11       ` Jan Kratochvil [this message]
2014-12-02  3:07         ` [patchv3 2/2] Accelerate lookup_symbol_aux_objfile 85x Doug Evans
2014-12-03 18:05           ` Jan Kratochvil
2014-12-04  6:21             ` Doug Evans
2014-12-04  7:27               ` [commit] " Jan Kratochvil
2014-10-22  8:57 ` [patch 0/2] Accelerate symbol lookups 15x Doug Evans
2014-10-24  7:19 ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141129121124.GA21606@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=xdje42@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).