From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
maennich@google.com
Subject: [PATCH v2] limit repeated DIE comparisons
Date: Thu, 9 Jun 2022 12:17:35 +0100 [thread overview]
Message-ID: <20220609111735.1488817-1-gprocida@google.com> (raw)
In-Reply-To: <20220609110627.1469252-1-gprocida@google.com>
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;
+ else
+ ++visit;
+
Dwarf_Off l_canonical_die_offset = 0, r_canonical_die_offset = 0;
const die_source l_die_source = ctxt.get_die_source(l);
const die_source r_die_source = ctxt.get_die_source(r);
--
2.36.1.255.ge46751e96f-goog
next prev parent reply other threads:[~2022-06-09 11:17 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 ` Giuliano Procida [this message]
2022-06-09 16:14 ` [PATCH v2] " Dodji Seketeli
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=20220609111735.1488817-1-gprocida@google.com \
--to=gprocida@google.com \
--cc=dodji@seketeli.org \
--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).