Skip to content

Commit

Permalink
refactored background batch eviction and added DSA support
Browse files Browse the repository at this point in the history
  • Loading branch information
guptask committed Oct 5, 2023
1 parent 2041678 commit 708513f
Show file tree
Hide file tree
Showing 17 changed files with 495 additions and 24 deletions.
4 changes: 1 addition & 3 deletions cachelib/allocator/BackgroundMover-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ namespace cachelib {

template <typename CacheT>
BackgroundMover<CacheT>::BackgroundMover(
Cache& cache,
std::shared_ptr<BackgroundMoverStrategy> strategy,
MoverDir direction)
Cache& cache, std::shared_ptr<BackgroundMoverStrategy> strategy, MoverDir direction)
: cache_(cache), strategy_(strategy), direction_(direction) {
if (direction_ == MoverDir::Evict) {
moverFunc = BackgroundMoverAPIWrapper<CacheT>::traverseAndEvictItems;
Expand Down
6 changes: 2 additions & 4 deletions cachelib/allocator/BackgroundMover.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BackgroundMover : public PeriodicWorker {
// (promoted vs. evicted and how much)
BackgroundMover(Cache& cache,
std::shared_ptr<BackgroundMoverStrategy> strategy,
MoverDir direction_);
MoverDir direction);

~BackgroundMover() override;

Expand Down Expand Up @@ -102,9 +102,7 @@ class BackgroundMover : public PeriodicWorker {
std::shared_ptr<BackgroundMoverStrategy> strategy_;
MoverDir direction_;

std::function<size_t(
Cache&, unsigned int, unsigned int, unsigned int, size_t)>
moverFunc;
std::function<size_t(Cache&, unsigned int, unsigned int, unsigned int, size_t)> moverFunc;

// implements the actual logic of running the background evictor
void work() override final;
Expand Down
2 changes: 2 additions & 0 deletions cachelib/allocator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ target_link_libraries(cachelib_allocator PUBLIC
cachelib_navy
cachelib_common
cachelib_shm
dml
dl
)

if ((CMAKE_SYSTEM_NAME STREQUAL Linux) AND
Expand Down
11 changes: 11 additions & 0 deletions cachelib/allocator/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,21 @@ void CacheBase::updateGlobalCacheStats(const std::string& statPrefix) const {

visitEstimates(uploadStatsNanoToMicro, stats.allocateLatencyNs,
statPrefix + "allocate.latency_us");

visitEstimates(uploadStatsNanoToMicro, stats.bgEvictLatencyNs,
statPrefix + "background.eviction.latency_us");
visitEstimates(uploadStatsNanoToMicro, stats.evictDmlLargeItemWaitLatencyNs,
statPrefix + "background.eviction.dml.large_item_wait.latency_us");
visitEstimates(uploadStatsNanoToMicro, stats.evictDmlSmallItemWaitLatencyNs,
statPrefix + "background.eviction.dml.small_item_wait.latency_us");

visitEstimates(uploadStatsNanoToMicro, stats.bgPromoteLatencyNs,
statPrefix + "background.promotion.latency_us");
visitEstimates(uploadStatsNanoToMicro, stats.promoteDmlLargeItemWaitLatencyNs,
statPrefix + "background.promotion.dml.large_item_wait.latency_us");
visitEstimates(uploadStatsNanoToMicro, stats.promoteDmlSmallItemWaitLatencyNs,
statPrefix + "background.promotion.dml.small_item_wait.latency_us");

visitEstimates(uploadStatsNanoToMicro, stats.moveChainedLatencyNs,
statPrefix + "move.chained.latency_us");
visitEstimates(uploadStatsNanoToMicro, stats.moveRegularLatencyNs,
Expand Down
Loading

0 comments on commit 708513f

Please sign in to comment.