From a2b6aca89700b15524bbc611e3f79def7a4953a1 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Tue, 19 Aug 2025 13:32:26 -0500 Subject: [PATCH 1/2] use gshash for more robust hash distribution --- include/gcache/ghost_kv_cache.h | 2 +- include/gcache/hash.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/gcache/ghost_kv_cache.h b/include/gcache/ghost_kv_cache.h index a7bc85c..b1cefd0 100644 --- a/include/gcache/ghost_kv_cache.h +++ b/include/gcache/ghost_kv_cache.h @@ -17,7 +17,7 @@ struct GhostKvMeta { * pair can be variable-length. By default support sampling (non-sampling * version can be acquired by setting SampleShift=0) */ -template , +template class SampledGhostKvCache { SampledGhostCache, SizeType, diff --git a/include/gcache/hash.h b/include/gcache/hash.h index f118615..5ccdcf9 100644 --- a/include/gcache/hash.h +++ b/include/gcache/hash.h @@ -64,4 +64,12 @@ struct murmurhash { uint32_t operator()(uint32_t x) const noexcept { return murmurhash_u32(x); } }; +/* Hash for string_view */ + +struct gshash { // default string hash function for gcache + uint32_t operator()(std::string_view x) const noexcept { + return crc32_u32(0x537, std::hash{}(x)); + } +}; + } // namespace gcache From cde32ceb489b4bde164b13a87220c3917c762773 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Tue, 19 Aug 2025 13:39:38 -0500 Subject: [PATCH 2/2] add const --- include/gcache/hash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gcache/hash.h b/include/gcache/hash.h index 5ccdcf9..9215f94 100644 --- a/include/gcache/hash.h +++ b/include/gcache/hash.h @@ -67,7 +67,7 @@ struct murmurhash { /* Hash for string_view */ struct gshash { // default string hash function for gcache - uint32_t operator()(std::string_view x) const noexcept { + uint32_t operator()(const std::string_view x) const noexcept { return crc32_u32(0x537, std::hash{}(x)); } };