This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Kill CLASSTYPE_SORTED_FIELDS


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]