This is an archive of the discontinued LLVM Phabricator instance.

Using murmurhash2 instead of fnv
ClosedPublic

Authored by rafael on Sep 12 2016, 8:49 AM.

Details

Reviewers
emaste
ruiu
davide
Summary

If this ok, once it is in I will experiment with xxhash to see if it is even better. I will also check if there is desire to move this (or xxhash) to llvm.

The speedups I got when building with llvm lto were

firefox

master 8.180250337
patch  7.205933333 1.13521038275x faster

chromium

master 4.43514035
patch  4.253562196 1.04268849158x faster

chromium fast

master 1.962154622
patch  1.805858212 1.08654965764x faster

the gold plugin

master 0.374364145
patch  0.322151729 1.16207398968x faster

clang

master 0.629810409
patch  0.548644689 1.1479385869x faster

llvm-as

master 0.036080885
patch  0.031719355 1.1375037418x faster

the gold plugin fsds

master 0.397731951
patch  0.348331855 1.1418190593x faster

clang fsds

master 0.707624537
patch  0.626803806 1.12894103422x faster

llvm-as fsds

master 0.032458039
patch  0.029188861 1.11200087595x faster

scylla

master 4.003780575
patch  3.23819983 1.2364217112x faster

and with gcc 6.1 (non lto):
firefox

master 7.7321452
patch  6.792662255 1.13830850258x faster

chromium

master 4.401358079
patch  4.231184832 1.04021881666x faster

chromium fast

master 1.99247151
patch  1.835671156 1.08541854214x faster

the gold plugin

master 0.379588529
patch  0.327329661 1.1596521007x faster

clang

master 0.636152202
patch  0.55581161 1.14454644443x faster

llvm-as

master 0.03697245
patch  0.032769466 1.12825915442x faster

the gold plugin fsds

master 0.404065327
patch  0.354658762 1.13930732945x faster

clang fsds

master 0.715435897
patch  0.635372078 1.12601091828x faster

llvm-as fsds

master 0.033349658
patch  0.030205179 1.1041039684x faster

scylla

master 3.807397873
patch  3.068759915 1.24069590925x faster

Diff Detail

Event Timeline

rafael updated this revision to Diff 71013.Sep 12 2016, 8:49 AM
rafael retitled this revision from to Using murmurhash2 instead of fnv.
rafael updated this object.
rafael added reviewers: ruiu, davide, emaste.
rafael added a subscriber: llvm-commits.
emaste added inline comments.Sep 12 2016, 10:03 AM
ELF/Driver.cpp
474

Should we allow the user a way to specify the fast, non-cryptographic hash --build-id=<something>? I think so, but I think the implementation detail (which of fnv1/murmur2/xxhash it actually is) is unnecessary.

emaste edited edge metadata.Sep 12 2016, 10:10 AM

If we don't care about collision resistance then xxhash should be faster (and may well be more collision-resistant, I don't know). If we do care about collision resistance then siphash should be almost as fast, and more resistant.

emaste accepted this revision.Sep 12 2016, 10:17 AM
emaste edited edge metadata.

That said, I believe this is as good or better than fnv1 in all aspects (other than being slightly more complex) so no reason to avoid making this change now and then investigating xxhash or siphash.

This revision is now accepted and ready to land.Sep 12 2016, 10:17 AM
ruiu added inline comments.Sep 12 2016, 10:29 AM
ELF/OutputSections.cpp
1744

I'd rename this class BuildIdNonCryptoHash or something like that because I think we'd want to change the implementation again in the future. Specifically, we want to use threads to make it faster, but if we do, it is no longer a Murmur hash (because Murmur(concat(X1, X2, ..., Xn)) is different from SomeHash(Murmur(X1), Murmur(X2), ..., Murmur(Xn)).)

emaste added inline comments.Sep 12 2016, 12:31 PM
ELF/OutputSections.cpp
1744

The same argument applies to the crypto hashes too; we may well want SomeHash(sha1(X1), sha1(X2), ..., sha1(Xn)). build-id doesn't specify exactly what parts of the file are included or how the hash is generated, and gold and bfd hash differently already.

Should we make it just BuildIdFastHash? It's not specifically non-crypto-ness of the hash that we're interested in, it's that it's as fast as possible.

rafael edited edge metadata.
ruiu accepted this revision.Sep 13 2016, 2:13 PM
ruiu edited edge metadata.

LGTM

davide accepted this revision.Sep 14 2016, 4:48 PM
davide edited edge metadata.

This looks good. Thanks for running the other benchmarks.

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r281454.