Skip to content
  • Tamar Christina's avatar
    Replace hashing function for string keys implementation with xxhash · 542f89ff
    Tamar Christina authored and Ben Gamari's avatar Ben Gamari committed
    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: #13165
    
    Differential Revision: https://phabricator.haskell.org/D3909
    542f89ff