-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add memcached support to index cache (#1881)
* Moved index cache key struct outside of the file containing the in-memory cache backend because generic Signed-off-by: Marco Pracucci <marco@pracucci.com> * Added cacheKey.string() to make it memcached friendly Signed-off-by: Marco Pracucci <marco@pracucci.com> * Added MemcachedIndexCache support Signed-off-by: Marco Pracucci <marco@pracucci.com> * Export Prometheus metrics from MemcachedIndexCache Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed linter issues Signed-off-by: Marco Pracucci <marco@pracucci.com> * Simplified workers wait group in memcachedClient Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed memcached client GetMulti() results batches channel buffer Signed-off-by: Marco Pracucci <marco@pracucci.com> * Wait for addrs resolution gorouting to complete on memcachedClient.Stop() Signed-off-by: Marco Pracucci <marco@pracucci.com> * Return struct from NewMemcachedClient() Signed-off-by: Marco Pracucci <marco@pracucci.com> * Update pkg/cacheutil/memcached_client.go Co-Authored-By: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: Marco Pracucci <marco@pracucci.com> * Simplified memcachedClient tests Signed-off-by: Marco Pracucci <marco@pracucci.com> * Cleaned up code based on feedback Signed-off-by: Marco Pracucci <marco@pracucci.com> * Removed error from GetMulti() return and introduced metrics and tracing in MemcachedClient Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed compilation errors in store E2E tests Signed-off-by: Marco Pracucci <marco@pracucci.com> * Added leaktest check to all tests Signed-off-by: Marco Pracucci <marco@pracucci.com> * Introduced --index.cache-config support Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed compilation errors in store E2E tests Signed-off-by: Marco Pracucci <marco@pracucci.com> * Updated store flags doc Signed-off-by: Marco Pracucci <marco@pracucci.com> * Updated index cache doc Signed-off-by: Marco Pracucci <marco@pracucci.com> * Updated changelog Signed-off-by: Marco Pracucci <marco@pracucci.com> * Increased default memcached client timeout from 100ms to 500ms Signed-off-by: Marco Pracucci <marco@pracucci.com> * Disabled memcached client max batch size by default Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed index cache key max length Signed-off-by: Marco Pracucci <marco@pracucci.com> * Removed TODO from memcached client since looks the general consensus is to have a global limit on the max concurrent batches Signed-off-by: Marco Pracucci <marco@pracucci.com> * Allow to configure in-memory index cache using byte units Signed-off-by: Marco Pracucci <marco@pracucci.com> * Refactored index cache config file doc Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed nits in comments Signed-off-by: Marco Pracucci <marco@pracucci.com> * Replaced hardcoded 16 with ULID calculated length based on review comment Signed-off-by: Marco Pracucci <marco@pracucci.com> * Do not expose jumpHash func Signed-off-by: Marco Pracucci <marco@pracucci.com> * Updated changelog Signed-off-by: Marco Pracucci <marco@pracucci.com> * Switched MemcachedClient GetMulti() concurrency limit to a gate Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed flaky tests Signed-off-by: Marco Pracucci <marco@pracucci.com> * Fixed typos in comments Signed-off-by: Marco Pracucci <marco@pracucci.com> * Renamed memcached config option addrs to addresses Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
- Loading branch information
Showing
23 changed files
with
2,104 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cacheutil | ||
|
||
// jumpHash consistently chooses a hash bucket number in the range | ||
// [0, numBuckets) for the given key. numBuckets must be >= 1. | ||
// | ||
// Copied from github.com/dgryski/go-jump/blob/master/jump.go (MIT license). | ||
func jumpHash(key uint64, numBuckets int) int32 { | ||
var b int64 = -1 | ||
var j int64 | ||
|
||
for j < int64(numBuckets) { | ||
b = j | ||
key = key*2862933555777941757 + 1 | ||
j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1))) | ||
} | ||
|
||
return int32(b) | ||
} |
Oops, something went wrong.