cache: split filter and index cache when sharing cache #5261
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.
Hi guys, while using Pebble, we've discovered that sharing the cache across multiple instances can be a better solution. However, we're based on Pebble 1.0, and the current pull request is a proof-of-concept. If you agree on the changes, I'll continue optimizing it to meet the merge requirements.
In our scenario, we've been using a single database, accumulating around 1.5TB of data. To reduce the pressure on the single database, we've used parallel commits and other methods. We plan to run on shards in the future, so we'll split the single database into eight shards, which will of course reduce the cache size and handles proportionally.
Although parallel commits work well, read performance and cache hit rate have decreased slightly. We've tried using a shared cache across eight shards.
Version 1:

The performance has deteriorated significantly. The flame graph shows a significant drop in the cache hit rate for readFilter. Analysis suggests this may be due to frequent evicts of the filter cache when using a shared cache. see #5242
Version 2:

We forked the Pebble code to isolate the filter and index caches. The performance difference is minimal compared to a single-DB cache.
Thank you for your review.