Three Unlikely Successful Features of D
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Mar 21 09:25:47 PDT 2012
On Tue, Mar 20, 2012 at 11:54:37PM -0600, Brad Anderson wrote:
[...]
> It's probably far too early to think about this with all the other
> important issues you're addressing but have you given much thought to
> improving the hashing function? I haven't hit any issues with the
> speed of the current hasher but better performance is always welcome.
> MurmurHash seems to be all the rage these days with a lot of languages
> and systems adopting it <http://en.wikipedia.org/wiki/MurmurHash> (it
> compiles down to ~52 instructions on x86). It'd be interesting to see
> benchmarks with it. I'm not sure where the current hashing function
> lives to see what it's like.
[...]
The current implementation actually has (at least) two different hash
functions:
- Paul Hsieh's SuperFastHash (rt.util.hash.hashOf)
- A custom hash for char[] and string: look in rt/typeinfo/ti_Ag.d for
class TypeInfo_Aa, which has this:
hash_t hash = 0;
foreach (char c; s)
hash = hash * 11 + c;
I'm going to benchmark both hash functions to see which is actually
faster. I suspect the custom hash is faster for small strings, though it
may not have good hash distribution.
T
--
Microsoft is to operating systems & security ... what McDonalds is to gourmet cooking.
More information about the Digitalmars-d
mailing list