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

Function adjust_histogram

libCacheSim/dataStructure/histogram.c:120–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void adjust_histogram(ReuseHistogram* hist, uint64_t total_requests, float rate) {
121 uint64_t total = hist->cold_miss_bin;
122 GHashTableIter iter;
123 gpointer key, value;
124 g_hash_table_iter_init(&iter, hist->bins);
125 while (g_hash_table_iter_next(&iter, &key, &value)) {
126 BinEntry* bin = (BinEntry*)value;
127 total += bin->frequency;
128 }
129
130 uint64_t expected = (uint64_t)(total_requests * rate);
131
132 if (expected > total) {
133 uint64_t diff = expected - total;
134 // Use get_min_distance to find the smallest distance bucket.
135 uint64_t min_distance = get_min_distance(hist);
136 if (min_distance != UINT64_MAX) {
137 BinEntry* bin = (BinEntry*)g_hash_table_lookup(hist->bins, &min_distance);
138 if (bin) {
139 bin->frequency += diff;
140 }
141 }
142 }
143}

Callers 1

generate_shards_mrcFunction · 0.85

Calls 1

get_min_distanceFunction · 0.85

Tested by

no test coverage detected