Comments (6)
Hi @Chokoabigail,
allocate
can fail if CacheAllocator
cannot find items to be evicted at the end of eviction queue. The maximum number of retries (say N) is determined by evictionSearchTries
and the eviction will be failed if none of the N items at the end of eviction queue for given allocation class are eligible to be evicted; i.e.,
To debug this, you can check how many handles are outstanding by checking CacheAllocator::getNumActiveHandles
.
If the number is much higher than expected, you need to take a look at the client code for any leaking handles.
Otherwise if the number is expected, I think you can retry after some delay.
Thanks.
from cachelib.
The client code is actually very simple, the most complex function is the PutKey
and in it, there is a concern for memory leaks.
What should I do with this code:
auto chainedItemHandle = gCache_->allocateChainedItem(parentItemHandle, chunkSize);
if (!chainedItemHandle)
{
...
}
It potentially can be after several successful chainedItemHandle
allocations (or none), should I call gCache_->remove(key);
on the same key I used in auto parentItemHandle = gCache_->allocate(defaultPool_, key, parentItemSize);
?
Should I call free on parentItemHandle
? Should I call free on every successful chainedItemHandle
allocation before the loop?
This is the rest of the client code:
std::string GetCacheStatus()
{
std::string res;
std::string seperator = "[::]";
res += "isNvmCacheEnabled: " + std::to_string(gCache_->isNvmCacheEnabled()) + seperator;
// Get the statistics map
auto statsMap = gCache_->getNvmCacheStatsMap();
for (const auto& kv : statsMap.getCounts()) {
std::string k = "statsMap.getCounts()" + kv.first + ":";
res += k + std::to_string(gCache_->isNvmCacheEnabled()) + seperator;
}
// Get the rate map
for (const auto& kv : statsMap.getRates()) {
std::string k = "statsMap.getRates()" + kv.first + ":";
res += k + std::to_string(gCache_->isNvmCacheEnabled()) + seperator;
}
return res;
}
bool RemoveKey(CacheKey key)
{
auto rr = gCache_->remove(key);
if (rr == Cache::RemoveRes::kSuccess) {
return true;
}
return false;
}
std::string GetKey(CacheKey key)
{
std::string result;
uint32_t fregmentNumber = 0;
auto parent = gCache_->find(key);
if (!parent)
{
return result;
}
auto iobuf_chainedItems = gCache_->convertToIOBuf(std::move(parent));
for (const auto& item : iobuf_chainedItems)
{
// First item is the parent item so we can continue over it
if (fregmentNumber == 0)
{
fregmentNumber++;
continue;
}
// Reconstruct the value
folly::StringPiece sp2{item};
result += sp2;
}
return result;
}
from cachelib.
@Chokoabigail As long as the handle is disposed, you are good. Those have zero references, so should be eligible to be evicted.
I can see you allocated 100MB for RAM cache, meaning you would have only 24 slabs or so. Some allocation class might not have enough slabs allocated or even 0. I would suggest check the distribution of slabs to alloc classes and what was the failing allocation class.
from cachelib.
@Chokoabigail As long as the handle is disposed, you are good. Those have zero references, so should be eligible to be evicted.
I can see you allocated 100MB for RAM cache, meaning you would have only 24 slabs or so. Some allocation class might not have enough slabs allocated or even 0. I would suggest check the distribution of slabs to alloc classes and what was the failing allocation class.
How can I do that? (p.s. In production, we have the same client with a 16GB of RAM, and it also fails there from time to time (once a month or so))
from cachelib.
@Chokoabigail You can refer to the ACStats which is part of the PoolStats returned by CacheAllocator::getPoolStats(...)
I noticed that there is no public support to print those stats. I think you can refer to the cachebench implementation here (-report_ac_memory_usage_stat
option)
from cachelib.
Let me close this for now. Feel free to reopen or open a new one if needed
from cachelib.
Related Issues (20)
- Profiling cachelib hotspots HOT 1
- The performance deterioration is observed in the new version
- compilation error HOT 3
- Create a version with stable facebook project dependencies HOT 1
- make_unique was not declared when compiled HOT 1
- Runtime error (seem to be caused by link error) HOT 4
- Fail to persist nvm cache due to "exceeding metadata limit" HOT 1
- Build failure - cannot find python-six HOT 2
- build.sh: error: failed to build cachelib HOT 2
- build.sh: error: No build recipe for detected operating system 'fedora38' HOT 3
- New runtime error HOT 5
- cachelib fails to build HOT 3
- allocator-test-AllocationClassTest Failed On ARM
- Where is `cachelib/facebook/admin/CacheAdmin.h`? HOT 1
- cachelib fails to build HOT 3
- refCount alignment issue HOT 4
- The method config.enableChainedItems() cannot be found. HOT 1
- Some questions in resizing the cachelib pool size HOT 2
- Is there any plan to provide an Java SDK for this cachelib ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cachelib.