This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Speed-up get_identifier("main") (take 4)
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>
- Date: Fri, 08 Aug 2003 13:23:22 -0700
- Subject: Re: [PATCH] Speed-up get_identifier("main") (take 4)
- References: <Pine.LNX.4.44.0308081323250.20517-100000@www.eyesopen.com>
Roger Sayle <roger@eyesopen.com> writes:
> The following version of the patch implements Richard Henderson's
> suggestion of changing the length argument to get_identifier_with_length
> to be size_t. I followed Neil Booth's and Zack's recommendation of
> also changing the argument types of ht_lookup and calc_hash to size_t
> but keeping the len field of ht_identifier "unsigned int", and casting
> down with an explicit cast in ht_lookup.
>
> Then whilst I was tweaking ht_lookup anyway, I also implemented a
> suggestion from Andi Kleen to optimize ht_lookup for the common cases
> where the first probe finds either an empty slot or a matching entry.
> In these cases, its possible to avoid calculating the secondary hash.
> Given GCC's identifier table initially contains 16K entries, most of
> the calls to ht_lookup on a small or medium input file should benefit,
> and there should be no slow down on larger source files.
>
>
> The following patch has been tested on i686-pc-linux-gnu with a
> complete "make bootstrap", all languages except treelang, and regression
> tested with a top-level "make -k check" with no new failures.
>
> Ok for mainline?
Ok.
zw
> 2003-08-08 Roger Sayle <roger@eyesopen.com>
>
> * tree.h (get_identifier) Define a macro form of get_identifier
> that calls get_identifier_with_length when the string is constant.
> (get_identifier_with_length): Change type of second argument to
> size_t in prototype.
> * stringpool.c (get_identifier): Undefine the macro before giving
> the function definition.
> (get_identifier_with_length): Change type of second argument to
> size_t in function definition.
> * hashtable.c (calc_hash): Change type of second argument to size_t.
> (ht_lookup): Change type of third argument to size_t. Reorganize
> to speed-up the cases where the hash table slot is empty, or the
> first probe matches (i.e. there isn't a collision).
> * hashtable.h (ht_lookup): Adjust function prototype.