|
28 | 28 | #include <stdexcept> |
29 | 29 | #include <vector> |
30 | 30 |
|
| 31 | +#include "cachelib/allocator/nvmcache/AccessTimeMap.h" |
31 | 32 | #include "cachelib/allocator/nvmcache/CacheApiWrapper.h" |
32 | 33 | #include "cachelib/allocator/nvmcache/InFlightPuts.h" |
33 | 34 | #include "cachelib/allocator/nvmcache/NavyConfig.h" |
@@ -589,6 +590,18 @@ class NvmCache { |
589 | 590 | // finished. |
590 | 591 | std::vector<folly::F14FastSet<std::string>> itemRemoved_; |
591 | 592 |
|
| 593 | + // Tracks the most recent DRAM last-access timestamp for items in NVM. |
| 594 | + // It is best offered and not updated on every DRAM access so could sometime |
| 595 | + // have stale value which represents the promotion timestamp. |
| 596 | + // Populated on DRAM eviction of NvmClean BlockCache items; |
| 597 | + // consumed during BlockCache region reclaim to write fresh timestamps. |
| 598 | + std::unique_ptr<AccessTimeMap> accessTimeMap_; |
| 599 | + |
| 600 | + // BigHash small-item threshold from NavyConfig. Items with |
| 601 | + // key.size() + nvmBufferSize <= this threshold go to BigHash. |
| 602 | + // 0 means BigHash is not configured and all items go to BlockCache. |
| 603 | + const uint64_t smallItemMaxSize_; |
| 604 | + |
592 | 605 | std::unique_ptr<cachelib::navy::AbstractCache> navyCache_; |
593 | 606 |
|
594 | 607 | friend class tests::NvmCacheTest; |
@@ -1058,7 +1071,15 @@ NvmCache<C>::NvmCache(C& c, |
1058 | 1071 | tombstones_(numShards_), |
1059 | 1072 | itemDestructor_(itemDestructor), |
1060 | 1073 | itemDestructorMutex_(numShards_), |
1061 | | - itemRemoved_(numShards_) { |
| 1074 | + itemRemoved_(numShards_), |
| 1075 | + accessTimeMap_( |
| 1076 | + config_.navyConfig.getEnableAccessTimeMap() |
| 1077 | + ? std::make_unique<AccessTimeMap>( |
| 1078 | + numShards_, config_.navyConfig.getAccessTimeMapMaxSize()) |
| 1079 | + : nullptr), |
| 1080 | + smallItemMaxSize_(config_.navyConfig.isBigHashEnabled() |
| 1081 | + ? config_.navyConfig.bigHash().getSmallItemMaxSize() |
| 1082 | + : 0) { |
1062 | 1083 | navyCache_ = createNavyCache( |
1063 | 1084 | config_.navyConfig, |
1064 | 1085 | checkExpired_, |
@@ -1644,6 +1665,9 @@ template <typename C> |
1644 | 1665 | util::StatsMap NvmCache<C>::getStatsMap() const { |
1645 | 1666 | util::StatsMap statsMap; |
1646 | 1667 | navyCache_->getCounters(statsMap.createCountVisitor()); |
| 1668 | + if (accessTimeMap_) { |
| 1669 | + accessTimeMap_->getCounters(statsMap.createCountVisitor()); |
| 1670 | + } |
1647 | 1671 | statsMap.insertCount("items_tracked_for_destructor", getNvmItemRemovedSize()); |
1648 | 1672 | return statsMap; |
1649 | 1673 | } |
|
0 commit comments