Skip to content

Commit 525370e

Browse files
pbhandar2meta-codesync[bot]
authored andcommitted
include map value in TTA calculation
Summary: Current stat computes TTA stat based on stale last accessed timestamp in NVM. This diff uses a fresh last accessed timestamp in the map if access time map is enabled and an entry exists for a given key. Reviewed By: rlyerly Differential Revision: D98856147 fbshipit-source-id: 60cb771b2197c730f6a9501de205fdfd88e4d627
1 parent fd51367 commit 525370e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

cachelib/allocator/nvmcache/NvmCache.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,12 +1381,17 @@ void NvmCache<C>::onGetComplete(GetCtx& ctx,
13811381
recordEvent(AllocatorApiEvent::NVM_FIND, hk.key(), AllocatorApiResult::FOUND,
13821382
nvmItem);
13831383

1384-
// Track NVM hit time-to-access for every NVM hit, regardless of whether
1385-
// the DRAM promotion succeeds (another thread may have already promoted).
1386-
// TTA = currentTime - lastAccessTimeSecs (how long ago item was last
1387-
// accessed). Guard > 0 because BigHash doesn't store access time.
1388-
if (lastAccessTimeSecs > 0) {
1389-
auto ttaSecs = util::getCurrentTimeSec() - lastAccessTimeSecs;
1384+
// Get the latest last accessed time if it ATM is enabled and an entry exists.
1385+
uint32_t latestLastAccessTimeSecs = lastAccessTimeSecs;
1386+
if (accessTimeMap_ && it->isNvmLargeItem()) {
1387+
auto atmEntry = accessTimeMap_->get(hk.keyHash());
1388+
if (atmEntry.has_value()) {
1389+
latestLastAccessTimeSecs =
1390+
std::max(latestLastAccessTimeSecs, atmEntry.value());
1391+
}
1392+
}
1393+
if (latestLastAccessTimeSecs > 0) {
1394+
auto ttaSecs = util::getCurrentTimeSec() - latestLastAccessTimeSecs;
13901395
stats().nvmHitTTASecs_.trackValue(ttaSecs);
13911396
}
13921397

0 commit comments

Comments
 (0)