public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dje at google dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/16998] New: perf improvements for searching GLOBAL_BLOCK
Date: Thu, 29 May 2014 19:49:00 -0000	[thread overview]
Message-ID: <bug-16998-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=16998

            Bug ID: 16998
           Summary: perf improvements for searching GLOBAL_BLOCK
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com

This pr is a corollary to pr 16994, and is for improving searching
GLOBAL_BLOCK.
[I'm trying to break down the entirety of gdb symbol problems into pieces -
there's just so many of them it's easier for me to keep track of them this way.
Still need one more bit of information to tie them together: I was thinking of
adding a "gdb-performance" "keyword".]

When .gdb_index was added, it was added in a way to let it easily sit along
side the psymtab implementation.  Which is totally reasonable as a first pass.

However, there is, I think, a performance cost.
The way gdb looks up global symbols (static ones too, but this bug is about
global symbols), is that it first searches already expanded symtabs and only if
not found there does gdb try the "quick_symbol_functions" API.

E.g.,

static int
lookup_symbol_global_iterator_cb (struct objfile *objfile,
                                  void *cb_data)
{
  struct global_sym_lookup_data *data =
    (struct global_sym_lookup_data *) cb_data;

  gdb_assert (data->result == NULL);

=>data->result = lookup_symbol_aux_objfile (objfile, GLOBAL_BLOCK,
                                            data->name, data->domain);
  if (data->result == NULL)
    data->result = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK,
                                            data->name, data->domain);

  /* If we found a match, tell the iterator to stop.  Otherwise,                
     keep going.  */
  return (data->result != NULL);
}

lookup_symbol_aux_objfile does this:

  ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
    {
      bv = BLOCKVECTOR (s);
      block = BLOCKVECTOR_BLOCK (bv, block_index);
=>    sym = lookup_block_symbol (block, name, domain);
      if (sym)
        {
          block_found = block;
          return fixup_symbol_section (sym, objfile);
        }
    }

Over time symtabs get expanded, so the list to iterate over here grows.
But .gdb_index knows exactly which symtab(s) to look in.
[for global symbols there is only one, hence the "(s)" suffix is a bit of a
misnomer, but I'm leaving that aside for now]
So why not just always use .gdb_index for GLOBAL_BLOCK lookups?
[That's an honest question, maybe I'm missing something.
Still digging.]

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2014-05-29 19:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-29 19:49 dje at google dot com [this message]
2014-05-29 20:37 ` [Bug symtab/16998] " dje at google dot com
2014-05-30  2:26 ` dje at google dot com
2023-02-11 17:04 ` tromey at sourceware dot org
2023-09-18  8:06 ` tromey at sourceware dot org

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=bug-16998-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).