Skip to content

Commit b157fe5

Browse files
authored
Fast path for short strings (#74)
This allows strings less than 8 bytes to be special cased to avoid the AES call as mentioned in #66 Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
1 parent 4b9c4ee commit b157fe5

8 files changed

+1719
-1635
lines changed

smhasher/0001-Add-support-for-aHash.patch

+41-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 426384ce34cf410d892eeeeeb7f6046d52bff8e7 Mon Sep 17 00:00:00 2001
1+
From 8d3446fbd6c73710ef2ea6bfe46fd3b7a1a787a7 Mon Sep 17 00:00:00 2001
22
From: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
3-
Date: Sat, 11 Jul 2020 17:15:56 -0700
4-
Subject: [PATCH] Add support for ahash
3+
Date: Wed, 13 Jan 2021 21:56:02 -0800
4+
Subject: [PATCH] Add support for aHash
55

66
---
77
CMakeLists.txt | 1 +
@@ -12,26 +12,32 @@ Subject: [PATCH] Add support for ahash
1212
create mode 100644 ahash.h
1313

1414
diff --git a/CMakeLists.txt b/CMakeLists.txt
15-
index 6ebab1a..9d79e98 100644
15+
index 3420a56..921d111 100644
1616
--- a/CMakeLists.txt
1717
+++ b/CMakeLists.txt
18-
@@ -470,10 +470,11 @@ add_executable(
19-
target_link_libraries(
20-
SMHasher
21-
SMHasherSupport
22-
${HIGHWAY_LIB}
23-
${BLAKE3_LIB}
24-
+ libahash_c.a
25-
${CMAKE_THREAD_LIBS_INIT}
26-
)
18+
@@ -638,14 +638,15 @@ if(ipo_supported)
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLTO")
20+
# set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS "-DLTO")
21+
else()
22+
message(STATUS "IPO / LTO not supported: <${error}>")
23+
endif()
2724

28-
#add_executable(
29-
# bittest
25+
target_link_libraries(SMHasher SMHasherSupport ${HIGHWAY_LIB} ${BLAKE3_LIB}
26+
+ libahash_c.a
27+
${CMAKE_THREAD_LIBS_INIT})
28+
29+
# add_executable( bittest bittest.cpp )
30+
#
31+
# target_link_libraries( bittest SMHasherSupport ${CMAKE_THREAD_LIBS_INIT} )
32+
33+
if(NOT (CMAKE_CROSSCOMPILING))
3034
diff --git a/Hashes.h b/Hashes.h
31-
index 4e111c1..fcd3e38 100644
35+
index 472f4e4..9fae4e9 100644
3236
--- a/Hashes.h
3337
+++ b/Hashes.h
34-
@@ -19,10 +19,11 @@
38+
@@ -17,14 +17,15 @@
39+
#include "opt_cmetrohash.h"
40+
3541
#if defined(__SSE4_2__) && defined(__x86_64__)
3642
#include "metrohash/metrohash64crc.h"
3743
#include "metrohash/metrohash128crc.h"
@@ -43,7 +49,11 @@ index 4e111c1..fcd3e38 100644
4349
#include "jody_hash64.h"
4450

4551
// objsize: 0-0x113 = 276
46-
@@ -356,10 +357,14 @@ inline void fasthash32_test ( const void * key, int len, uint32_t seed, void * o
52+
#include "tifuhash.h"
53+
// objsize: 5f0-85f = 623
54+
@@ -356,14 +357,18 @@ inline void cmetrohash64_2_test ( const void * key, int len, uint32_t seed, void
55+
inline void fasthash32_test ( const void * key, int len, uint32_t seed, void * out ) {
56+
*(uint32_t*)out = fasthash32(key, (size_t) len, seed);
4757
}
4858
#ifdef HAVE_INT64
4959
inline void fasthash64_test ( const void * key, int len, uint32_t seed, void * out ) {
@@ -58,6 +68,8 @@ index 4e111c1..fcd3e38 100644
5868
// objsize 0-778: 1912
5969
void mum_hash_test(const void * key, int len, uint32_t seed, void * out);
6070

71+
inline void mum_low_test ( const void * key, int len, uint32_t seed, void * out ) {
72+
uint64_t result;
6173
diff --git a/ahash.h b/ahash.h
6274
new file mode 100644
6375
index 0000000..6c59caf
@@ -114,22 +126,26 @@ index 0000000..6c59caf
114126
+#endif
115127
\ No newline at end of file
116128
diff --git a/main.cpp b/main.cpp
117-
index 04060f2..7489aaf 100644
129+
index e9cf20d..ae3d273 100644
118130
--- a/main.cpp
119131
+++ b/main.cpp
120-
@@ -263,11 +263,11 @@ HashInfo g_hashes[] =
121-
122-
{ xxh3_test, 64, 0x39CD9E4A, "xxh3", "xxHash v3, 64-bit", GOOD },
123-
{ xxh3low_test, 32, 0xFAE8467B, "xxh3low", "xxHash v3, 64-bit, low 32-bits part", GOOD },
124-
{ xxh128_test, 128, 0xEB61B3A0, "xxh128", "xxHash v3, 128-bit", GOOD },
125-
{ xxh128low_test, 64, 0x54D1CC70, "xxh128low", "xxHash v3, 128-bit, low 64-bits part", GOOD },
132+
@@ -302,15 +302,15 @@ HashInfo g_hashes[] =
133+
{ MeowHash64_test, 64, 0xB04AC842, "MeowHash64low","MeowHash (requires x64 AES-NI)", POOR },
134+
{ MeowHash128_test, 128, 0xA0D29861, "MeowHash", "MeowHash (requires x64 AES-NI)", POOR },
135+
#endif
136+
{ t1ha1_64le_test, 64, 0xD6836381, "t1ha1_64le", "Fast Positive Hash (portable, aims 64-bit, little-endian)", POOR },
137+
{ t1ha1_64be_test, 64, 0x93F864DE, "t1ha1_64be", "Fast Positive Hash (portable, aims 64-bit, big-engian)", POOR },
138+
{ t1ha0_32le_test, 64, 0x7F7D7B29, "t1ha0_32le", "Fast Positive Hash (portable, aims 32-bit, little-endian)", POOR },
139+
{ t1ha0_32be_test, 64, 0xDA6A4061, "t1ha0_32be", "Fast Positive Hash (portable, aims 32-bit, big-endian)", POOR },
126140
-
127141
+ { ahash64_test, 64, 0x00000000, "ahash64", "ahash 64bit", GOOD }, //Expected value set to zero because aHash does not adhere to a fixed output.
128142
#if __WORDSIZE >= 64
129143
# define TIFU_VERIF 0x644236D4
130144
#else
131145
// broken on certain travis
132146
# define TIFU_VERIF 0x0
147+
#endif
148+
// and now the quality hash funcs, slowest first
133149
--
134150
2.25.1
135151

0 commit comments

Comments
 (0)