MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / rank

Method rank

libCacheSim/cache/eviction/LHD/lhd.cpp:35–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35candidate_t LHD::rank(const request_t* req) {
36 uint64_t victim = -1;
37 rank_t victimRank = std::numeric_limits<rank_t>::max();
38
39 // Sample few candidates early in the trace so that we converge
40 // quickly to a reasonable policy.
41 //
42 // This is a hack to let us have shorter warmup so we can evaluate
43 // a longer fraction of the trace; doesn't belong in a real
44 // system.
45 uint32_t candidates = (numReconfigurations > 50) ? ASSOCIATIVITY : 8;
46
47 for (uint32_t i = 0; i < candidates; i++) {
48 auto idx = next_rand() % tags.size();
49 auto& tag = tags[idx];
50 rank_t rank = getHitDensity(tag);
51
52 if (rank < victimRank) {
53 victim = idx;
54 victimRank = rank;
55 }
56 }
57
58 for (uint32_t i = 0; i < ADMISSIONS; i++) {
59 auto itr = indices.find(recentlyAdmitted[i]);
60 if (itr == indices.end()) {
61 continue;
62 }
63
64 auto idx = itr->second;
65 auto& tag = tags[idx];
66 assert(tag.id == recentlyAdmitted[i]);
67 rank_t rank = getHitDensity(tag);
68
69 if (rank < victimRank) {
70 victim = idx;
71 victimRank = rank;
72 }
73 }
74
75 assert(victim != (uint64_t)-1);
76
77 ewmaVictimHitDensity =
78 EWMA_DECAY * ewmaVictimHitDensity + (1 - EWMA_DECAY) * victimRank;
79
80 return tags[victim].id;
81}
82
83void LHD::update(candidate_t id, const request_t* req) {
84 auto itr = indices.find(id);

Callers 2

LHD_to_evictFunction · 0.45
LHD_evictFunction · 0.45

Calls 5

assertFunction · 0.85
next_randFunction · 0.50
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected