qt5base-lts/tests/auto/corelib/tools/qhashfunctions
Lars Knoll f14559790b Change qHashBits to use MurmurHash2
The old implementation was either using CRC32 on modern processors
or a trivial, but rather slow implementation.

We can't continue with CRC32, as that implementation can only
give us 32bit hashes, where we now need to support 64bit in Qt 6.

Change the implementation to use MurmurHash, as public domain
implementation that is both very fast and leads to well distributed hashes.

This hash function is about as fast as the SSE optimized CRC32 implementation
but works everywhere and gives us 64 bit hash values.

Here are some numbers (time for 10M hashes):

                                         14 char     16 char
                                         QByteArray  QString  float
old qHash (non CRC32)                    127ms       134ms    48ms
old qHash (using SSE CRC32 instructions  60ms        62ms     46ms
new qHash                                52ms        43ms     46ms

Unfortunately MurmurHash is not safe against hash table DoS attacks, as
potential hash collisions are indepenent of the seed. This will get
addressed in followup commit, where we use SipHash or an SSE optimized
AES based hashing algorithm that does not have those issues.

Change-Id: I4fbc0ac299215b6db78c7a0a2a1d7689b0ea848b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-04-09 20:03:45 +02:00
..
.gitignore tst_QHash: Factor qHash()-related test cases into a separate test 2015-01-05 20:18:51 +01:00
CMakeLists.txt Regenerate tests/auto/corelib/tools 2019-11-12 17:26:27 +00:00
qhashfunctions.pro Tests: Remove CONFIG += parallel_test. 2015-09-05 07:16:50 +00:00
tst_qhashfunctions.cpp Change qHashBits to use MurmurHash2 2020-04-09 20:03:45 +02:00