Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions in resizing the cachelib pool size #287

Closed
KIDSSCC opened this issue Jan 26, 2024 · 2 comments
Closed

Some questions in resizing the cachelib pool size #287

KIDSSCC opened this issue Jan 26, 2024 · 2 comments

Comments

@KIDSSCC
Copy link

KIDSSCC commented Jan 26, 2024

Hello,I apologize for the disturbance.In our current work scenario,we want to create cache for multiple threads while each thread performs independent cache storage.Refering to the following section in the Cachelib User Guide,

If you're using multiple cache instances, please consider if you can simplify to using a single instance via multiple cache pools. CacheLib is highly optimized for concurrency; using multiple cachelib instances is typically an anti-pattern unless you have a good reason.

We are now using multiple cache pools while each pool corresponds to one thread and use key prefix to avoid the same key. At runtime,we hope to resize pool size dynamically.However,we now find that when resizeing the pool(especially when shrink pool size) sometimes the memory has not been properly released。
For example,I add 2 pools each with a size of 1GB named A and B in the cachelib instance with a size of 2GB and in A and B, each stored 1GB of data respectively(poolStat.freeMemoryBytes() now equal to 0).I call the resizePools method to move 512MB from A to B.After the function call,the poolStat.freeMemoryBytes() of A is 0 and that of B is 512MB.But I can't store more items in the pool B.Is that the correct features or I make some mistakes in pool using?
Or, alternatively, may I use the multiple cachelib instances instead of multiple pools? If so, How should I resize a cache after it has been created? Our core requirement is that when shrink the size of a pool or a cache.a portion of the stored items should be evicted from the cache according to the corresponding eviction policy if necessary(no enough free space in the pool ).I would greatly appreciate

@jaesoo-fb
Copy link
Contributor

Hi @KIDSSCC,

Just in case, have you enabled the pool resizing? As you know, the pool resize is performed asynchronously.

Or, alternatively, may I use the multiple cachelib instances instead of multiple pools?

The size of Cache is static once instantiated, so the resizing of the cache instance is not supported.

@KIDSSCC
Copy link
Author

KIDSSCC commented Feb 4, 2024

Hi, @jaesoo-fb .Thanks very much,I have solved my problem with your repyl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants