summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-14 16:50:52 +0200
committerTyge Løvset <[email protected]>2023-04-14 16:50:52 +0200
commit462adebf55c77697fbb379a62941c00b876c3f6a (patch)
tree737a2c5cdc6bd69f6e739ae666d8e8a44e62b33c
parent0516aa3ae823ed9a22b2c5f776948c8447c32c31 (diff)
downloadSTC-modified-462adebf55c77697fbb379a62941c00b876c3f6a.tar.gz
STC-modified-462adebf55c77697fbb379a62941c00b876c3f6a.zip
tuning of hash function. Adjusted benchmark balance.
-rw-r--r--include/stc/ccommon.h8
-rw-r--r--misc/benchmarks/plotbench/cdeq_benchmark.cpp2
-rw-r--r--misc/benchmarks/plotbench/clist_benchmark.cpp2
-rw-r--r--misc/benchmarks/plotbench/cvec_benchmark.cpp2
-rw-r--r--misc/benchmarks/shootout_hashmaps.cpp2
-rw-r--r--src/singleupdate.sh54
6 files changed, 35 insertions, 35 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index d5508807..bc12e642 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -147,14 +147,14 @@ STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) {
case 0: return 1;
}
const uint8_t *x = (const uint8_t*)key;
- uint64_t h = *x, n = (uint64_t)len >> 3;
+ uint64_t h = 0xcbf29ce484222325 + *x*0x811c9dc5UL, n = (uint64_t)len >> 3;
len &= 7;
while (n--) {
memcpy(&u8, x, 8), x += 8;
- h += u8*0xc6a4a7935bd1e99d;
+ h = (h ^ u8)*0x01000193UL;
}
- while (len--) h = (h << 10) - h - *x++;
- return c_ROTL(h, 26) ^ h;
+ while (len--) h = (h ^ *x++)*0x01000193UL;
+ return h;
}
STC_INLINE uint64_t cstrhash(const char *str)
diff --git a/misc/benchmarks/plotbench/cdeq_benchmark.cpp b/misc/benchmarks/plotbench/cdeq_benchmark.cpp
index bb0e28c8..54d7305b 100644
--- a/misc/benchmarks/plotbench/cdeq_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cdeq_benchmark.cpp
@@ -12,7 +12,7 @@ enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 2, N = 50000000, S = 0x3ffc, R = 4};
+enum {SAMPLES = 2, N = 60000000, S = 0x3ffc, R = 4};
uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
diff --git a/misc/benchmarks/plotbench/clist_benchmark.cpp b/misc/benchmarks/plotbench/clist_benchmark.cpp
index 01bfbf83..703222b3 100644
--- a/misc/benchmarks/plotbench/clist_benchmark.cpp
+++ b/misc/benchmarks/plotbench/clist_benchmark.cpp
@@ -12,7 +12,7 @@ enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 2, N = 10000000, S = 0x3ffc, R = 4};
+enum {SAMPLES = 2, N = 25000000, S = 0x3ffc, R = 4};
uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
diff --git a/misc/benchmarks/plotbench/cvec_benchmark.cpp b/misc/benchmarks/plotbench/cvec_benchmark.cpp
index c488a01c..3b4c3d7d 100644
--- a/misc/benchmarks/plotbench/cvec_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cvec_benchmark.cpp
@@ -12,7 +12,7 @@ enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 2, N = 80000000, S = 0x3ffc, R = 4};
+enum {SAMPLES = 2, N = 40000000, S = 0x3ffc, R = 4};
uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
diff --git a/misc/benchmarks/shootout_hashmaps.cpp b/misc/benchmarks/shootout_hashmaps.cpp
index bae9a42b..debff31d 100644
--- a/misc/benchmarks/shootout_hashmaps.cpp
+++ b/misc/benchmarks/shootout_hashmaps.cpp
@@ -35,7 +35,7 @@ KHASH_MAP_INIT_INT64(ii, IValue)
// cmap template expansion
#define i_key IKey
#define i_val IValue
-#define i_ssize int32_t // enable 2^K buckets like the rest.
+//#define i_ssize int32_t // enable 2^K buckets like the rest.
#define i_tag ii
#define i_max_load_factor MAX_LOAD_FACTOR / 100.0f
#include <stc/cmap.h>
diff --git a/src/singleupdate.sh b/src/singleupdate.sh
index d9a16568..9b1d37a0 100644
--- a/src/singleupdate.sh
+++ b/src/singleupdate.sh
@@ -1,27 +1,27 @@
-d=$(git rev-parse --show-toplevel)
-mkdir -p $d/../stcsingle/c11 $d/../stcsingle/stc
-python singleheader.py $d/include/c11/print.h > $d/../stcsingle/c11/print.h
-python singleheader.py $d/include/stc/calgo.h > $d/../stcsingle/stc/calgo.h
-python singleheader.py $d/include/stc/carc.h > $d/../stcsingle/stc/carc.h
-python singleheader.py $d/include/stc/cbits.h > $d/../stcsingle/stc/cbits.h
-python singleheader.py $d/include/stc/cbox.h > $d/../stcsingle/stc/cbox.h
-python singleheader.py $d/include/stc/ccommon.h > $d/../stcsingle/stc/ccommon.h
-python singleheader.py $d/include/stc/cdeq.h > $d/../stcsingle/stc/cdeq.h
-python singleheader.py $d/include/stc/clist.h > $d/../stcsingle/stc/clist.h
-python singleheader.py $d/include/stc/cmap.h > $d/../stcsingle/stc/cmap.h
-python singleheader.py $d/include/stc/coption.h > $d/../stcsingle/stc/coption.h
-python singleheader.py $d/include/stc/cpque.h > $d/../stcsingle/stc/cpque.h
-python singleheader.py $d/include/stc/cqueue.h > $d/../stcsingle/stc/cqueue.h
-python singleheader.py $d/include/stc/crand.h > $d/../stcsingle/stc/crand.h
-python singleheader.py $d/include/stc/cregex.h > $d/../stcsingle/stc/cregex.h
-python singleheader.py $d/include/stc/cset.h > $d/../stcsingle/stc/cset.h
-python singleheader.py $d/include/stc/csmap.h > $d/../stcsingle/stc/csmap.h
-python singleheader.py $d/include/stc/cspan.h > $d/../stcsingle/stc/cspan.h
-python singleheader.py $d/include/stc/csset.h > $d/../stcsingle/stc/csset.h
-python singleheader.py $d/include/stc/cstack.h > $d/../stcsingle/stc/cstack.h
-python singleheader.py $d/include/stc/cstr.h > $d/../stcsingle/stc/cstr.h
-python singleheader.py $d/include/stc/csview.h > $d/../stcsingle/stc/csview.h
-python singleheader.py $d/include/stc/cvec.h > $d/../stcsingle/stc/cvec.h
-python singleheader.py $d/include/stc/extend.h > $d/../stcsingle/stc/extend.h
-python singleheader.py $d/include/stc/forward.h > $d/../stcsingle/stc/forward.h
-echo "stcsingle headers updated" \ No newline at end of file
+d=$(git rev-parse --show-toplevel)
+mkdir -p $d/../stcsingle/c11 $d/../stcsingle/stc
+python singleheader.py $d/include/c11/print.h > $d/../stcsingle/c11/print.h
+python singleheader.py $d/include/stc/calgo.h > $d/../stcsingle/stc/calgo.h
+python singleheader.py $d/include/stc/carc.h > $d/../stcsingle/stc/carc.h
+python singleheader.py $d/include/stc/cbits.h > $d/../stcsingle/stc/cbits.h
+python singleheader.py $d/include/stc/cbox.h > $d/../stcsingle/stc/cbox.h
+python singleheader.py $d/include/stc/ccommon.h > $d/../stcsingle/stc/ccommon.h
+python singleheader.py $d/include/stc/cdeq.h > $d/../stcsingle/stc/cdeq.h
+python singleheader.py $d/include/stc/clist.h > $d/../stcsingle/stc/clist.h
+python singleheader.py $d/include/stc/cmap.h > $d/../stcsingle/stc/cmap.h
+python singleheader.py $d/include/stc/coption.h > $d/../stcsingle/stc/coption.h
+python singleheader.py $d/include/stc/cpque.h > $d/../stcsingle/stc/cpque.h
+python singleheader.py $d/include/stc/cqueue.h > $d/../stcsingle/stc/cqueue.h
+python singleheader.py $d/include/stc/crand.h > $d/../stcsingle/stc/crand.h
+python singleheader.py $d/include/stc/cregex.h > $d/../stcsingle/stc/cregex.h
+python singleheader.py $d/include/stc/cset.h > $d/../stcsingle/stc/cset.h
+python singleheader.py $d/include/stc/csmap.h > $d/../stcsingle/stc/csmap.h
+python singleheader.py $d/include/stc/cspan.h > $d/../stcsingle/stc/cspan.h
+python singleheader.py $d/include/stc/csset.h > $d/../stcsingle/stc/csset.h
+python singleheader.py $d/include/stc/cstack.h > $d/../stcsingle/stc/cstack.h
+python singleheader.py $d/include/stc/cstr.h > $d/../stcsingle/stc/cstr.h
+python singleheader.py $d/include/stc/csview.h > $d/../stcsingle/stc/csview.h
+python singleheader.py $d/include/stc/cvec.h > $d/../stcsingle/stc/cvec.h
+python singleheader.py $d/include/stc/extend.h > $d/../stcsingle/stc/extend.h
+python singleheader.py $d/include/stc/forward.h > $d/../stcsingle/stc/forward.h
+echo "$d/../stcsingle headers updated"