This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [cxx-conversion] New Hash Table (issue6244048)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Lawrence Crowl <crowl at google dot com>
- Cc: reply at codereview dot appspotmail dot com, dnovillo at google dot com, gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 May 2012 08:25:24 +0200
- Subject: Re: [cxx-conversion] New Hash Table (issue6244048)
- References: <20120524164342.DDF542225E1@jade.mtv.corp.google.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, May 24, 2012 at 09:43:42AM -0700, Lawrence Crowl wrote:
> Add a type-safe hash table, typed_htab. Uses of this table replace
> uses of libiberty's htab_t. The benefits include less boiler-plate
> code, full type safety, and improved performance.
You haven't looked at the most important problem of that approach -
code bloat. hashtab.o .text is currently ~ 4KB on x86_64, in your version
only very small part out of it is shared. In a cc1plus binary I count
roughly 179 htab_create{,_ggc} calls, ignoring the first parameter (initial
size) that is roughly 139 unique hash/eq/del fn combinations, thus you'll
end up with over hundred copies of most of the hashtab code, in many of the
cases performance critical and thus its I-cache friendliness is quite
important.
> Static functions are also not acceptable as template arguments, so
> this patch externalizes the functions. To avoid potential name
> conflicts, the function names have been prefixed.
Ugh. I guess the C++ way around this would be to put the functions into
anonymous namespace.
> + /* Return the current size of this hash table. */
> +
> + size_t size()
> + {
> + return htab->size;
> + }
(and various other places) - formatting is wrong, missing space between (.
> +void
> +typed_htab <Element, Hash, Equal, Remove, Allocator>
> +::dispose ()
Do we want to format methods this way?
Jakub