Skip to content

Commit e111395

Browse files
igchorvinser52
authored andcommitted
Initial multi-tier support implementation
1 parent 9812286 commit e111395

File tree

11 files changed

+398
-189
lines changed

11 files changed

+398
-189
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
@@ -74,7 +74,7 @@ enum class DestructorContext {
7474
// A base class of cache exposing members and status agnostic of template type.
7575
class CacheBase {
7676
public:
77-
CacheBase() = default;
77+
CacheBase(unsigned numTiers = 1);
7878
virtual ~CacheBase() = default;
7979

8080
// Movable but not copyable
@@ -83,6 +83,9 @@ class CacheBase {
8383
CacheBase(CacheBase&&) = default;
8484
CacheBase& operator=(CacheBase&&) = default;
8585

86+
// TODO: come up with some reasonable number
87+
static constexpr unsigned kMaxTiers = 8;
88+
8689
// Get a string referring to the cache name for this cache
8790
virtual const std::string getCacheName() const = 0;
8891

@@ -271,6 +274,10 @@ class CacheBase {
271274
// @return The number of slabs that were actually reclaimed (<= numSlabs)
272275
virtual unsigned int reclaimSlabs(PoolId id, size_t numSlabs) = 0;
273276

277+
unsigned getNumTiers() const;
278+
279+
unsigned numTiers_ = 1;
280+
274281
// Protect 'poolRebalanceStragtegies_' and `poolResizeStrategies_`
275282
// and `poolOptimizeStrategy_`
276283
mutable std::mutex lock_;

0 commit comments

Comments
 (0)