Replace hashing function for string keys implementation with xxhash

Authored by Phyx on Sep 4 2017, 7:02 AM.

Description

Replace hashing function for string keys implementation with xxhash

When doing profiling on startup time of ghci on Windows, both cold and
startup loading static LLVM libs, the profiler is showing a glaring red
spot on the division operation of the the hashStr function.

In fact profiling shows 14% of the time is spent hashing the keys.

So I am replacing the hash function with xxHash which is a very fast
non-crypto hash. It's faster than MurMurHash which node etc use.

It also passes SMHasher. I can provide if required the collected raw
data. But from analysis done on the keys, xxHash does not introduce
more collisions than before, the amount splits seem about the same and
the distributions among the buckets are slightly more uniform than
before.

However the runtime dropped enough to remove the function completely
from the profiler's report.

There's also a noticeable improvement in responsiveness.

xxHash is BSD licensed and can be found
https://github.com/Cyan4973/xxHash

Test Plan: ./validate

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: Trac #13165

Differential Revision: https://phabricator.haskell.org/D3909

Details

Committed
bgamariSep 5 2017, 6:20 AM
Reviewer
bgamari
Differential Revision
D3909: Replace hashing function for string keys implementation with xxhash
Parents
rGHCa4c2ac2cef3d: get-win32-tarballs: Use correct `find`
Branches
Unknown
Tags
Unknown