This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Kill CLASSTYPE_SORTED_FIELDS
- From: Michael Matz <matz at suse dot de>
- To: Nathan Sidwell <nathan at acm dot org>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 28 Aug 2017 18:58:47 +0200 (CEST)
- Subject: Re: [C++ PATCH] Kill CLASSTYPE_SORTED_FIELDS
- Authentication-results: sourceware.org; auth=none
- References: <70b2cf9b-fa5e-9572-386a-bd36cf010862@acm.org>
Hi,
On Mon, 28 Aug 2017, Nathan Sidwell wrote:
> This patch replaces the sorted field vector with a hash map. Lookup for
> non-function members of a complete class is now O(1), not O(log(n)).
> We still do linear lookup when the class is incomplete. Fixing that is
> still on the todo list.
Have you any memory measurement on a non-trivial C++ codebase with many
classes (template instantiations?)? On LP64 platforms the sorted list
for n members was 8+8*n bytes, the hash-map is 48 bytes itself plus 16*n
bytes for the entries, where you have at least 13 entries always, next 31,
next 61 entries (and so on). You pay the price for the next larger chunk
already at about 2/3 fill rate, so e.g a class with 10 members was 88
bytes before and is 544 bytes now, which doesn't look that attractive
given that the lookup before took four tries and now takes one, especially
taking into account cache effects.
Ciao,
Michael.