aboutsummaryrefslogtreecommitdiff
path: root/gdb/configure.ac
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-09-27 13:32:07 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-10-22 11:47:24 -0500
commitccb1ba62299edce72053dd567b9d384814e11885 (patch)
tree2bea3a6796df3af2f866e854bef525d7a4d18b79 /gdb/configure.ac
parent1a6ff1a96b302283d517b3cdeae7310adecbe859 (diff)
downloadgdb-ccb1ba62299edce72053dd567b9d384814e11885.zip
gdb-ccb1ba62299edce72053dd567b9d384814e11885.tar.gz
gdb-ccb1ba62299edce72053dd567b9d384814e11885.tar.bz2
Use libxxhash for hashing, if present
XXHash is faster than htab_hash_string: ------------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------------ BM_xxh3 11 ns 11 ns 65887249 BM_xxh32 19 ns 19 ns 36511877 BM_xxh64 16 ns 16 ns 42964585 BM_hash_string 182 ns 182 ns 3853125 BM_iterative_hash 77 ns 77 ns 9087638 Unfortunately, XXH3 is still experimental (see https://github.com/Cyan4973/xxHash#user-content-new-experimental-hash-algorithm) However, regular XXH64 is still a lot faster than htab_hash_string per my benchmark above. I used the following string for the benchmark: static constexpr char str[] = "_ZZZL13make_gdb_typeP7gdbarchP10tdesc_typeEN16gdb_type_creator19make_gdb_type_flagsEPK22tdesc_type_with_fieldsE19__PRETTY_FUNCTION__"; htab_hash_string is currently 4.35% + 7.98% (rehashing) of gdb startup when attaching to Chrome's content_shell. An additional 5.21% is spent in msymbol_hash, which does not use this hash function. Unfortunately, since it has to lowercase the string, it can't use this hash function. BM_msymbol_hash 52 ns 52 ns 13281495 It may be worth investigating if strlen+XXHash is still faster than htab_hash_string, which would make it easier to use in more places. Debian ships xxhash as libxxhash{0,-dev}. Fedora ships it as xxhash-devel. gdb/ChangeLog: 2019-10-22 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Link with libxxhash. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Search for libxxhash. * utils.c (fast_hash): Use xxhash if present. Change-Id: Icab218388b9f829522ed3977f04301ae6d4fc4ca
Diffstat (limited to 'gdb/configure.ac')
-rw-r--r--gdb/configure.ac23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/configure.ac b/gdb/configure.ac
index dbe0150..6297502 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2217,6 +2217,29 @@ else
fi
fi
+# Check for xxhash
+AC_ARG_WITH(xxhash,
+ AC_HELP_STRING([--with-xxhash], [use libxxhash for hashing (faster) (auto/yes/no)]),
+ [], [with_xxhash=auto])
+
+if test "x$with_xxhash" != "xno"; then
+ AC_LIB_HAVE_LINKFLAGS([xxhash], [],
+ [#include <xxhash.h>],
+ [XXH32("foo", 3, 0);
+ ])
+ if test "$HAVE_LIBXXHASH" != yes; then
+ if test "$with_xxhash" = yes; then
+ AC_MSG_ERROR([xxhash is missing or unusable])
+ fi
+ fi
+ if test "x$with_xxhash" = "xauto"; then
+ with_xxhash="$HAVE_LIBXXHASH"
+ fi
+fi
+
+AC_MSG_CHECKING([whether to use xxhash])
+AC_MSG_RESULT([$with_xxhash])
+
NM_H=
rm -f nm.h
if test "${nativefile}" != ""; then