Skip to content

Minimum Limit For Cache Allocation? #316

@aaditya2200

Description

@aaditya2200

Hi,

I have been using cachelib to build a swap space. I want the cache to be of a certain size based on an input parameter, and I have designed it as follows:

cache::cache(backing_store *bs, uint64_t n)
: backstore(bs), max_in_memory_objects(n) {
auto itemDestructor =
[&](const facebook::cachelib::LruAllocator::DestructorData &data) {
write_back(data.item);
};
Cache::Config config;
config.setCacheSize(1 * sizeof(object) * n)
.setCacheName("Lru_nodes")
.setAccessConfig({25, 10})
.setItemDestructor(itemDestructor)
.validate();
gcache_ = std::make_unique(config);
default_pool = gcache_->addPool("default_pool",
gcache_->getCacheMemoryStats().ramCacheSize);
}

n here is the cache size as an input parameter. What I have noticed is that for small values of n, the allocation fails with the error

E20240526 08:58:46.625504 68212 ExceptionTracer.cpp:222] exception stack complete
terminate called after throwing an instance of 'std::invalid_argument'
what(): not enough memory for slabs

The minimum n for which I can get an allocation seems to be 150K. I was wondering if there is any lower bound to the amount of memory we can allocate?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions