public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Matthias Maennich <maennich@google.com>
To: Dodji Seketeli <dodji@seketeli.org>
Cc: libabigail@sourceware.org, gprocida@google.com, kernel-team@android.com
Subject: Re: [PATCH 3/5] XML writer: track emitted types by bare pointer
Date: Thu, 16 Dec 2021 16:07:23 +0000	[thread overview]
Message-ID: <YbtkO/e81Ike+vG9@google.com> (raw)
In-Reply-To: <87ilvwrawm.fsf@seketeli.org>

Hi Dodji!

Thanks for the review and thanks for your thoughts!

On Fri, Dec 10, 2021 at 11:50:49AM +0100, Dodji Seketeli wrote:
>Hello,
>
>Matthias Maennich <maennich@google.com> a écrit:
>
>[...]
>
>> This is a performance and safety improvement made possible by the
>> previous changes which ensure that the same pointers are inserted and
>> looked up.
>>
>> This essentially removes the now unnecessary deep comparison.
>
>[...]
>
>> +++ b/src/abg-writer.cc
>> @@ -123,14 +123,10 @@ typedef unordered_map<type_base*,
>>  		      abigail::diff_utils::deep_ptr_eq_functor> type_ptr_map;
>>
>>  // A convenience typedef for a set of type_base*.
>> -typedef unordered_set<const type_base*, type_hasher,
>> -		      abigail::diff_utils::deep_ptr_eq_functor>
>> -type_ptr_set_type;
>> +typedef std::unordered_set<const type_base*> type_ptr_set_type;
>>
>>  /// A convenience typedef for a set of function type*.
>> -typedef unordered_set<function_type*, type_hasher,
>> -		      abigail::diff_utils::deep_ptr_eq_functor>
>> -fn_type_ptr_set_type;
>> +typedef std::unordered_set<function_type*> fn_type_ptr_set_type;
>
>The problem I see with doing this is that it's possible that two
>declaration-only classes, that are equivalent but that have different
>pointer values get into these sets.
>
>In that case, they would be considered different even though they are
>not.

If the XML writer considers two equivalent declaration-only types to be
different, one question to ask is: what is the real difference, that is,
how will this affect the outcome of abidiff? If the types never change
(kind, name or declaration/definition status), nothing should ever be
reported. If a type does change... there are two possibilities: either
the types were really one type and now perhaps abidiff reports diffs for
the same name in two different ways; or the types were really two
different ones and abidiff has a simpler job. In my experience, abidiff
doesn't always report declaration-only/defined transitions. It doesn't
sound like there will be any really bad impact on diffs from having this
kind of duplication. However, if someone can come up with a test case of
the kind you mention, that would give some extra reassurance.

>
>So maybe it would be better have an equality operator that uses
>is_non_canonicalized_type() to detect those rare cases and use
>structural comparison in those cases?

That might come at higher cost than it is beneficial.

>
>What do you think?

For us specifically - building with clang and for our use cases - if we
keep structural equality of any kind then we need a hash function to go
along with this and, as we've sadly found out, this isn't working well
at the moment. We are currently on a bit dated version of libabigail for
our production use, but would like to close that gap again to come
closer to master.

The risk of infinite loops and the reality of 30x slowdowns for certain
workloads mean we would need to apply these changes to remove structural
equality testing from the XML writer and then maintain an Android
version of libabigail as a more heavily-patched fork, to whatever extent
is feasible. I would rather we find a good solution that works for all
to get again close to upstream and not having to maintain such a fork.

Yet, as an additional piece of assurance: the testing we have done does
not only include kernels, but of course we heavily examined the
libabigail test suite. Additionally, we maintain a large set of small
test cases specifically created for ABI stability testing and to cover
corner cases of all sorts. We are in the process of publishing those as
well. So far, this has served as great input for this patch series as
well.

Does this make sense? What do you think?

Cheers,
Matthias

>
>-- 
>		Dodji

  reply	other threads:[~2021-12-16 16:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 11:46 [PATCH 0/5] Improvements for the XML Writer Matthias Maennich
2021-12-03 11:46 ` [PATCH 1/5] XML writer: use consistent type pointers for type ids and emission tracking Matthias Maennich
2021-12-09 17:57   ` Dodji Seketeli
2021-12-03 11:46 ` [PATCH 2/5] XML writer: use exemplar types for tracking referenced types Matthias Maennich
2021-12-10 10:42   ` Dodji Seketeli
2021-12-03 11:46 ` [PATCH 3/5] XML writer: track emitted types by bare pointer Matthias Maennich
2021-12-10 10:50   ` Dodji Seketeli
2021-12-16 16:07     ` Matthias Maennich [this message]
2022-01-10 17:00       ` Dodji Seketeli
2022-01-17 18:03         ` Matthias Maennich
2022-01-18 17:15   ` Dodji Seketeli
2021-12-03 11:46 ` [PATCH 4/5] XML writer: map type ids " Matthias Maennich
2022-01-19 10:12   ` Dodji Seketeli
2021-12-03 11:46 ` [PATCH 5/5] XML writer: resolve declaration-only enum definitions Matthias Maennich
2022-01-19 10:38   ` 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=YbtkO/e81Ike+vG9@google.com \
    --to=maennich@google.com \
    --cc=dodji@seketeli.org \
    --cc=gprocida@google.com \
    --cc=kernel-team@android.com \
    --cc=libabigail@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).