Skip to content

Commit a043394

Browse files
Async eviction implementation
TODO: - support for chained items - exposing per-tier statistics - support for temporary mappings (CacheAllocator ctor without ShmSharedNew/Attach)
2 parents 3e303d3 + 1856a24 commit a043394

25 files changed

+1168
-239
lines changed

cachelib/allocator/Cache.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
namespace facebook {
2424
namespace cachelib {
2525

26+
CacheBase::CacheBase(unsigned numTiers): numTiers_(numTiers) {}
27+
28+
unsigned CacheBase::getNumTiers() const {
29+
return numTiers_;
30+
}
31+
2632
void CacheBase::setRebalanceStrategy(
2733
PoolId pid, std::shared_ptr<RebalanceStrategy> strategy) {
2834
std::unique_lock<std::mutex> l(lock_);

cachelib/allocator/Cache.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum class RemoveContext { kEviction, kNormal };
5656
// A base class of cache exposing members and status agnostic of template type.
5757
class CacheBase {
5858
public:
59-
CacheBase() = default;
59+
CacheBase(unsigned numTiers = 1);
6060
virtual ~CacheBase() = default;
6161

6262
// Movable but not copyable
@@ -65,6 +65,9 @@ class CacheBase {
6565
CacheBase(CacheBase&&) = default;
6666
CacheBase& operator=(CacheBase&&) = default;
6767

68+
// TODO: come up with some reasonable number
69+
static constexpr unsigned kMaxTiers = 8;
70+
6871
// Get a string referring to the cache name for this cache
6972
virtual const std::string getCacheName() const = 0;
7073

@@ -253,6 +256,10 @@ class CacheBase {
253256
// @return The number of slabs that were actually reclaimed (<= numSlabs)
254257
virtual unsigned int reclaimSlabs(PoolId id, size_t numSlabs) = 0;
255258

259+
unsigned getNumTiers() const;
260+
261+
unsigned numTiers_ = 1;
262+
256263
// Protect 'poolRebalanceStragtegies_' and `poolResizeStrategies_`
257264
// and `poolOptimizeStrategy_`
258265
mutable std::mutex lock_;

0 commit comments

Comments
 (0)