Diskcache: querier-local SSD backed chunk cache#685
Merged
bboreham merged 12 commits intocortexproject:masterfrom Feb 22, 2018
Merged
Diskcache: querier-local SSD backed chunk cache#685bboreham merged 12 commits intocortexproject:masterfrom
bboreham merged 12 commits intocortexproject:masterfrom
Conversation
- Caches don't know about chunk anymore, its all just []byte. - Deal with empty memcached host by returning a noopCache, not special casing nil client. - Make background writes a cache 'middleware'. - s/memcache/memcached/. - Refactor tests.
- mmap a large file, treat it as a series of 2KB buckets. - Use FNV hash to place key and chunk in buckets. - Use existing memcached tests
Contributor
Author
|
We've had this running for about a week without problems. Performance impact is hard to measure, we see the diskcache taking about 0.5ms vs 33ms memcache (99th percentile fetch), but a relatively low hit rate of 70% vs memcache which is always at 100%. Given that this is disabled by default, I think the PR is worth it just for the refactoring. |
bboreham
approved these changes
Feb 20, 2018
Contributor
bboreham
left a comment
There was a problem hiding this comment.
I would be ok with merging after nits are fixed.
pkg/chunk/chunk_store.go
Outdated
| // ProcessCacheResponse decodes the chunks coming back from the cache, separating | ||
| // hits and misses. | ||
| func ProcessCacheResponse(chunks []Chunk, keys []string, bufs [][]byte) (found []Chunk, missing []Chunk, err error) { | ||
| ctx := NewDecodeContext() |
Contributor
There was a problem hiding this comment.
ctx jars - I would expect that to be a context.Context
pkg/chunk/chunk_store.go
Outdated
| cacheCorrupt = prometheus.NewCounter(prometheus.CounterOpts{ | ||
| Namespace: "cortex", | ||
| Name: "cache_corrupt_chunks_total", | ||
| Help: "Total count of corrupt chunks found in memcache.", |
pkg/chunk/cache/instrumented.go
Outdated
| fetchedKeys = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
| Namespace: "cortex", | ||
| Name: "cache_fetched_keys", | ||
| Help: "Total count of chunks requested from memcache.", |
pkg/chunk/cache/instrumented.go
Outdated
| hits = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
| Namespace: "cortex", | ||
| Name: "cache_hits", | ||
| Help: "Total count of chunks found in memcache.", |
Contributor
Author
|
Thanks @bboreham |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An on-disk cache, for caching chunks on local SSD in queriers. Uses a large mmap'd file, treated as a series of 2KB buckets, uses FNV hash to place key and chunk in buckets.
Also a bunch of refactoring of the memcache module, see commits.
Still a work in progress, will update with results.