public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 05/13] [gdb/symtab] Resolve deferred entries, inter-shard case
Date: Tue, 12 Dec 2023 12:27:52 -0700	[thread overview]
Message-ID: <87cyvbcjbb.fsf@tromey.com> (raw)
In-Reply-To: <20231212173239.16793-6-tdevries@suse.de> (Tom de Vries's message of "Tue, 12 Dec 2023 18:32:31 +0100")

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> +cooked_index_entry parent_map::deferred((sect_offset)0, (dwarf_tag)0,
Tom> +					(cooked_index_flag)0, nullptr,
Tom> +					nullptr, nullptr);

Several missing spaces.

However see the other note.  Maybe this isn't needed.

Tom>  cooked_index::cooked_index (vec_type &&vec)
Tom>    : m_vector (std::move (vec))
Tom>  {
Tom> +  handle_deferred_entries ();
Tom> +
Tom>    for (auto &idx : m_vector)
Tom>       idx->finalize ();

Here, parent resolution is single-threaded.  However, I think it can
probably be handled entirely in finalize -- and therefore distributed to
worker threads.  However, some changes are needed.

Tom> +const cooked_index_entry *
Tom> +cooked_index::find_parent_deferred_entry
Tom> +  (const cooked_index_shard::deferred_entry &entry) const
Tom> +{
Tom> +  const cooked_index_entry *parent_entry = nullptr;
Tom> +  for (auto &parent_map_shard : m_vector)
Tom> +    {
Tom> +      auto res = parent_map_shard->find_parent (entry.spec_offset);

The main issue with threading is that addrmaps are not thread-safe.
They are implemented as splay trees and these restructure themselves
during lookups.

However, I'm not sure we need splay trees.  Instead, it seems to me that
the relevant parts of the DIE tree can be handled with a sorted vector
that maps DIE ranges to entries.

Then, parent resolution can be done by binary search, and this can be
done by each shard in parallel -- and in particular, in do_finalize,
because that is already visiting every entry anyway.

Tom> +void
Tom> +cooked_index::handle_deferred_entries ()
Tom> +{
Tom> +  bool changed;
Tom> +  bool deferred;
Tom> +  do
Tom> +    {
Tom> +      deferred = false;
Tom> +      changed = false;
Tom> +      for (auto &shard : m_vector)
Tom> +	for (auto it = shard->m_deferred_entries->begin ();
Tom> +	     it != shard->m_deferred_entries->end (); )
Tom> +	  {
Tom> +	    const cooked_index_entry *parent_entry
Tom> +	      = find_parent_deferred_entry (*it);
Tom> +	    if (parent_entry == &parent_map::deferred)
Tom> +	      {
Tom> +		deferred = true;
Tom> +		it++;
Tom> +		continue;
Tom> +	      }
Tom> +	    shard->resolve_deferred_entry (*it, parent_entry);
Tom> +	    it = shard->m_deferred_entries->erase (it);
Tom> +	    changed = true;

I don't really understand this method.

What is the scenario leading to the need for 'deferred' and multiple
iterations?

Tom> +  for (auto &shard : m_vector)
Tom> +    {
Tom> +      shard->m_die_range_map.reset (nullptr);
Tom> +      shard->m_deferred_entries.reset (nullptr);
Tom> +    }
Tom> +}

In the background reading series, there's a new cooked_index_worker that
holds data that is needed before scanning is complete.  These things
could be put there instead.

Tom

  reply	other threads:[~2023-12-12 19:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 17:32 [PATCH v2 00/13] [gdb/symtab, cc-with-dwz] Fix gdb.cp/breakpoint-locs.exp Tom de Vries
2023-12-12 17:32 ` [PATCH v2 01/13] [gdb/symtab] Refactor condition in scan_attributes Tom de Vries
2023-12-12 18:28   ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 02/13] [gdb/symtab] Factor out m_die_range_map usage Tom de Vries
2023-12-12 18:31   ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 03/13] [gdb/symtab] Handle nullptr parent in parent_map::set_parent Tom de Vries
2023-12-12 18:34   ` Tom Tromey
2023-12-13  8:25     ` Tom de Vries
2023-12-13 20:11       ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 04/13] [gdb/symtab] Factor out m_deferred_entries usage Tom de Vries
2023-12-12 18:39   ` Tom Tromey
2023-12-13  8:46     ` Tom de Vries
2023-12-13 20:16       ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 05/13] [gdb/symtab] Resolve deferred entries, inter-shard case Tom de Vries
2023-12-12 19:27   ` Tom Tromey [this message]
2023-12-13 10:35     ` Tom de Vries
2023-12-13 20:19       ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 06/13] [gdb/testsuite] Add gdb.dwarf2/forward-spec-inter-cu.exp Tom de Vries
2023-12-12 19:28   ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 07/13] [gdb/testsuite] Add gdb.dwarf2/backward-spec-inter-cu.exp Tom de Vries
2023-12-12 19:29   ` Tom Tromey
2023-12-12 17:32 ` [PATCH v2 08/13] [gdb/symtab] Keep track of processed DIEs in shard Tom de Vries
2023-12-12 17:32 ` [PATCH v2 09/13] [gdb/symtab] Resolve deferred entries, intra-shard case Tom de Vries
2023-12-12 17:32 ` [PATCH v2 10/13] [gdb/symtab] Don't defer backward refs, inter-cu " Tom de Vries
2023-12-12 17:32 ` [PATCH v2 11/13] [gdb/symtab] Recurse into c++ DW_TAG_subprogram DIEs for cooked index Tom de Vries
2023-12-12 17:32 ` [PATCH v2 12/13] [gdb/symtab] Keep track of all parents " Tom de Vries
2023-12-12 17:32 ` [PATCH v2 13/13] [gdb/symtab] Fix DW_TAG_inlined_subroutine entries in the " Tom de Vries
2023-12-12 19:05 ` [PATCH v2 00/13] [gdb/symtab, cc-with-dwz] Fix gdb.cp/breakpoint-locs.exp Tom Tromey
2023-12-13  9:58   ` Tom de Vries
2023-12-13 20:14     ` Tom Tromey

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=87cyvbcjbb.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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).