Skip to content

Commit c353e25

Browse files
bbarenblatcopybara-github
authored andcommitted
Eliminate AArch64-specific code paths from LowLevelHash
After internal investigation, it’s no longer clear that the alternative LowLevelHash mixer committed in a05366d unequivocally improves performance on AArch64. It unnecessarily reduces performance on Apple Silicon and the AWS Graviton. It also lowers hash quality, which offsets much of the performance gain it provides on the Arm Neoverse N1 (see abseil#1093). Switch back to the original mixer. Closes: abseil#1093 PiperOrigin-RevId: 493941913 Change-Id: I84c789b2f88c91dec22f6f0f6e8c5129d2939a6f
1 parent 523b869 commit c353e25

File tree

4 files changed

+0
-62
lines changed

4 files changed

+0
-62
lines changed

absl/hash/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ cc_library(
157157
deps = [
158158
"//absl/base:config",
159159
"//absl/base:endian",
160-
"//absl/numeric:bits",
161160
"//absl/numeric:int128",
162161
],
163162
)

absl/hash/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ absl_cc_library(
140140
COPTS
141141
${ABSL_DEFAULT_COPTS}
142142
DEPS
143-
absl::bits
144143
absl::config
145144
absl::endian
146145
absl::int128

absl/hash/internal/low_level_hash.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,16 @@
1515
#include "absl/hash/internal/low_level_hash.h"
1616

1717
#include "absl/base/internal/unaligned_access.h"
18-
#include "absl/numeric/bits.h"
1918
#include "absl/numeric/int128.h"
2019

2120
namespace absl {
2221
ABSL_NAMESPACE_BEGIN
2322
namespace hash_internal {
2423

2524
static uint64_t Mix(uint64_t v0, uint64_t v1) {
26-
#if !defined(__aarch64__)
27-
// The default bit-mixer uses 64x64->128-bit multiplication.
2825
absl::uint128 p = v0;
2926
p *= v1;
3027
return absl::Uint128Low64(p) ^ absl::Uint128High64(p);
31-
#else
32-
// The default bit-mixer above would perform poorly on some ARM microarchs,
33-
// where calculating a 128-bit product requires a sequence of two
34-
// instructions with a high combined latency and poor throughput.
35-
// Instead, we mix bits using only 64-bit arithmetic, which is faster.
36-
uint64_t p = v0 ^ absl::rotl(v1, 40);
37-
p *= v1 ^ absl::rotl(v0, 39);
38-
return p ^ (p >> 11);
39-
#endif
4028
}
4129

4230
uint64_t LowLevelHash(const void* data, size_t len, uint64_t seed,

absl/hash/internal/low_level_hash_test.cc

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -452,54 +452,6 @@ TEST(LowLevelHashTest, VerifyGolden) {
452452
0xdd497891465a2cc1, 0x6f1fe8c57a33072e, 0x2c9f4ec078c460c0,
453453
0x9a725bde8f6a1437, 0x6ce545fa3ef61e4d,
454454
};
455-
#elif defined(__aarch64__)
456-
constexpr uint64_t kGolden[kNumGoldenOutputs] = {
457-
0x45c0aadee165dcbe, 0x25ed8587f6f20d06, 0x5f23ae668ce7926d,
458-
0xfef74d1da0846719, 0x54478408e68cb7d4, 0xee27ddaf88c6fe68,
459-
0xb7ac7031e81867ca, 0xf1168f818ec6c36d, 0x1dd0b734a83b019a,
460-
0xd6ae30d4142b54fe, 0xcd860c721ccb80fb, 0x068acf8493794756,
461-
0xd4ada0be58681307, 0x13ffe0f64ca540ed, 0xffc1d7a3401aec02,
462-
0xd81c4d865cf95fb9, 0x1dd0793acede62e0, 0xa6722abbca8fe4cf,
463-
0x5453d3e4111a7e40, 0xf29b3e3204c9dcd2, 0x23be2980e43117f7,
464-
0x74e2ccbc286f08eb, 0x19ef7c0f9496003a, 0xbfbf1c3e49b27987,
465-
0x6e6c179eb4a82c70, 0x07f4e184216bc4fc, 0xf17fbc4254927554,
466-
0xe57696b70a45b1b6, 0x6d3b144631b320e8, 0xccf8729792c75a2d,
467-
0xe832495b41fa980b, 0x5c96cfdc7b227d34, 0xc4dca234ef4e43f4,
468-
0x5fc801abf9abe307, 0xe41e3c5076d88f4d, 0x522346200ddec3c3,
469-
0x72bed1946fd7aaa4, 0x0ac1f84dcc335f96, 0x3af78db5e0a47670,
470-
0x6100ebf1481f1caf, 0xf5fd10037fc651a3, 0xa01227d8944665f3,
471-
0x7217681c4bbc9420, 0x4adee538e3eb10d1, 0x35e1761ad96de9a7,
472-
0x8b370aef9613bfba, 0x824506f749eeaf59, 0x85e805fa04423991,
473-
0xb61e9c33283c3de7, 0xc79721bbcb039ed6, 0x04e1c19a3a1e6639,
474-
0x6aaf6346b68dd638, 0x601a4b496be6d0c4, 0x3ece355f91c41787,
475-
0xd2fc8998448d7888, 0xd7529804f843efa9, 0xabdcc38a288536aa,
476-
0xdd323e48a9718648, 0x2090279c0030a52a, 0xe2f90faca88a3cd1,
477-
0x3e0c4e92fc50e4aa, 0xa26d308798e801dd, 0x432eefeedee8c02e,
478-
0xca4ce494614b77df, 0xbba82911e838066d, 0x4b00821016adee4b,
479-
0x4cf6e526dfb5a20f, 0x5b8466495142cba2, 0xe28ac1406e88a68c,
480-
0x8511e5f9d3100999, 0x05acbfe02798890b, 0x74c249c7ce4a8425,
481-
0xdbe7468d09bc34bc, 0x11079ab10e3b9b58, 0xb7788dec9032035a,
482-
0xb7e8daa786513f80, 0x34c3288831f46b45, 0x014cce5f0c21ecc6,
483-
0xc6a8f7b024551a28, 0x49784e902e207fd8, 0x4720d32af0b55158,
484-
0x8df3ec5de0c1da00, 0xf4db677b2c9e6853, 0xaa419abea78d312d,
485-
0x181e0f91bd757443, 0xa8c45136fada083b, 0x91303b93f5f0582c,
486-
0x883b95c6ddc62a08, 0x93186a8875fe952b, 0xd94f533928e957e2,
487-
0x6ba343003e10c172, 0xc8623b620c715d6a, 0x8ca0c512e180e244,
488-
0xdc9b74c2536b6216, 0x8eb5fdc61b295d96, 0x2ad83966b37c95ba,
489-
0xb90bf154ac5edec9, 0x902cf847b326cfb3, 0x7b02d0c0ca7808ca,
490-
0x492f310d003ea15f, 0x3eb6497a47c95990, 0x5d46b0ced31428b7,
491-
0x081afa67d1986157, 0x043482ec286b20eb, 0xc103c8f18c1a2a53,
492-
0xe8e9995a81481e83, 0x6bb3295822bc90b5, 0xeec75297a3fa5672,
493-
0x591c8440c4857412, 0x74947f455aaf24ad, 0xcf0e571586ec77a9,
494-
0x0c2553ea8c0400ad, 0x380219118066255f, 0x7595adb88b15ebe2,
495-
0xb33c00696c64ae23, 0xa143516ddd7c9857, 0x39179af229248d26,
496-
0x65d387a6f2ee2079, 0x89f8a9b21cd2f195, 0xbfef032d25df92e6,
497-
0x6b7e18a36c69da71, 0x4b3b15f6c28974e6, 0x032a75917f6c544c,
498-
0xe3b97ecca6d287cd, 0xa4a563110d3cda81, 0x35e09e8134f4e7f1,
499-
0xc9419dd03a9a390e, 0x7b86fae9000fd329, 0x1e044f8d54fe74c3,
500-
0x9c4991d7a47e9666, 0xfb485f3a1df4fdb6, 0xb11519969eeb94ff,
501-
0x3224ea1c44caeb8d, 0x86570bbd7cc6b80d,
502-
};
503455
#else
504456
constexpr uint64_t kGolden[kNumGoldenOutputs] = {
505457
0xe5a40d39ab796423, 0x1766974bf7527d81, 0x5c3bbbe230db17a8,

0 commit comments

Comments
 (0)