public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@seketeli.org>
To: Giuliano Procida <gprocida@google.com>
Cc: libabigail@sourceware.org,  kernel-team@android.com,
	 maennich@google.com
Subject: Re: [PATCH v2] limit repeated DIE comparisons
Date: Thu, 09 Jun 2022 18:14:45 +0200	[thread overview]
Message-ID: <8735gdlsp6.fsf@seketeli.org> (raw)
In-Reply-To: <20220609111735.1488817-1-gprocida@google.com> (Giuliano Procida's message of "Thu, 9 Jun 2022 12:17:35 +0100")

Hello,

Giuliano Procida <gprocida@google.com> a écrit:

I have applied the patch, thanks a lot for it!

I just have one useless comment below, for my own understanding.

> Exponential explosion of DIE comparison has been possible since the
> limit of at most 5 pending struct/union DIE comparison pairs was
> lifted.
>
> This commit adds two things to control this (with a negligible chance of
> falsely finding that two DIEs are equivalent when they are not).
>
> - DIE self-comparisons immediately return true
> - once a DIE pair has been compared 10000 times, always return true
>
> 	* src/abg-dwarf-reader.cc (read_context): Add mutable
> 	die_comparison_visits_ member.
> 	(compare_dies): Return true if this is a self-comparison.
> 	Return true if we have visited this comparison 10000 times.
>
> Signed-off-by: Giuliano Procida <gprocida@google.com>
> ---
>  src/abg-dwarf-reader.cc | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
> index 7bf2375d..27dd4faf 100644
> --- a/src/abg-dwarf-reader.cc
> +++ b/src/abg-dwarf-reader.cc
> @@ -2094,6 +2094,9 @@ public:
>    /// A map that associates a function type representations to
>    /// function types, inside a translation unit.
>    mutable istring_fn_type_map_type per_tu_repr_to_fn_type_maps_;
> +  mutable std::unordered_map<std::pair<Dwarf_Off, Dwarf_Off>,
> +			     size_t,
> +			     dwarf_offset_pair_hash> die_comparison_visits_;
>  
>    die_class_or_union_map_type	die_wip_classes_map_;
>    die_class_or_union_map_type	alternate_die_wip_classes_map_;
> @@ -10216,6 +10219,15 @@ compare_dies(const read_context& ctxt,
>  
>    Dwarf_Off l_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(l)),
>      r_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(r));
> +
> +  if (l_offset == r_offset)
> +    return true;
> +  auto& visit = ctxt.die_comparison_visits_[std::make_pair(l_offset, r_offset)];
> +  if (visit == 10000)
> +    return true;

Interesting.  I'll play with this and see what happens when we hit
this.  I hope I'll find a binary in the testsuite that hits this line,
so that I can understand why the type is compared so many times.

Thanks a lot!

[...]

Cheers,

-- 
		Dodji

      reply	other threads:[~2022-06-09 16:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 11:06 [PATCH] " Giuliano Procida
2022-06-09 11:17 ` [PATCH v2] " Giuliano Procida
2022-06-09 16:14   ` Dodji Seketeli [this message]

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=8735gdlsp6.fsf@seketeli.org \
    --to=dodji@seketeli.org \
    --cc=gprocida@google.com \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.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).