diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-12-02 18:58:35 -0600 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-12-03 15:27:15 -0600 |
commit | 4cbd39b289b012782df2fdda9adc7eacdcfc6ad7 (patch) | |
tree | f52aba927c48c83dca2923c7c3c0c55657ca29c1 /gdb/bcache.h | |
parent | 82f910ea9cce04b0faabfcd022d9d8949567541e (diff) | |
download | gdb-4cbd39b289b012782df2fdda9adc7eacdcfc6ad7.zip gdb-4cbd39b289b012782df2fdda9adc7eacdcfc6ad7.tar.gz gdb-4cbd39b289b012782df2fdda9adc7eacdcfc6ad7.tar.bz2 |
Replace hash function from bcache with fast_hash
This function is not just slower than xxhash, it is slower than
even libiberty's iterative_hash, so there does not seem to be
a reason for it to exist.
------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------
BM_xxh3 11 ns 11 ns 66127192
BM_xxh32 19 ns 19 ns 36792609
BM_xxh64 16 ns 16 ns 42941328
BM_city32 26 ns 26 ns 27028370
BM_city64 17 ns 17 ns 40472793
BM_iterative_hash 77 ns 77 ns 9088854
BM_bcache_hash 125 ns 125 ns 5599232
gdb/ChangeLog:
2019-12-03 Christian Biesinger <cbiesinger@google.com>
* bcache.c (hash): Remove.
(hash_continue): Remove.
* bcache.h (hash): Remove.
(hash_continue): Remove.
(struct bcache) <ctor>: Update.
* psymtab.c (psymbol_hash): Update.
* stabsread.c (hashname): Update.
* utils.h (fast_hash): Add an argument for a start value,
defaulting to zero.
Change-Id: I107f013eda5fdd3293326b5a206be43155dae0f8
Diffstat (limited to 'gdb/bcache.h')
-rw-r--r-- | gdb/bcache.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gdb/bcache.h b/gdb/bcache.h index 15dcc63..f26f79d 100644 --- a/gdb/bcache.h +++ b/gdb/bcache.h @@ -138,23 +138,18 @@ struct bstring; -/* The hash functions */ -extern unsigned long hash (const void *addr, int length); -extern unsigned long hash_continue (const void *addr, int length, - unsigned long h); - struct bcache { /* Allocate a bcache. HASH_FN and COMPARE_FN can be used to pass in custom hash, and compare functions to be used by this bcache. If - HASH_FUNCTION is NULL hash() is used and if COMPARE_FUNCTION is + HASH_FUNCTION is NULL fast_hash() is used and if COMPARE_FUNCTION is NULL memcmp() is used. */ explicit bcache (unsigned long (*hash_fn)(const void *, int length) = nullptr, int (*compare_fn)(const void *, const void *, int length) = nullptr) - : m_hash_function (hash_fn == nullptr ? hash : hash_fn), + : m_hash_function (hash_fn == nullptr ? default_hash : hash_fn), m_compare_function (compare_fn == nullptr ? compare : compare_fn) { } @@ -217,6 +212,12 @@ private: /* Default compare function. */ static int compare (const void *addr1, const void *addr2, int length); + /* Default hash function. */ + static unsigned long default_hash (const void *ptr, int length) + { + return fast_hash (ptr, length, 0); + } + /* Expand the hash table. */ void expand_hash_table (); }; |