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

Function cache_get_base

libCacheSim/cache/cache.c:223–252  ·  view source on GitHub ↗

* @brief this function is called by all eviction algorithms * it performs the following logic * * ``` * if obj in cache: * update_metadata * return true * else: * if cache does not have enough space: * evict until it has space to insert * insert the object * return false * ``` * * @param cache * @param req * @return true if cache hit, false if cache miss */

Source from the content-addressed store, hash-verified

221 * @return true if cache hit, false if cache miss
222 */
223bool cache_get_base(cache_t *cache, const request_t *req) {
224 cache->n_req += 1;
225
226 VERBOSE("******* %s req %ld, obj %ld, obj_size %ld, cache size %ld/%ld\n", cache->cache_name, cache->n_req,
227 req->obj_id, req->obj_size, cache->get_occupied_byte(cache), cache->cache_size);
228
229 cache_obj_t *obj = cache->find(cache, req, true);
230 bool hit = (obj != NULL);
231
232 if (cache->admissioner && cache->admissioner->update) {
233 cache->admissioner->update(cache->admissioner, req, cache->cache_size);
234 }
235
236 if (hit) {
237 VVERBOSE("req %ld, obj %ld --- cache hit\n", cache->n_req, req->obj_id);
238 } else if (!cache->can_insert(cache, req)) {
239 VVERBOSE("req %ld, obj %ld --- cache miss cannot insert\n", cache->n_req, req->obj_id);
240 } else {
241 while (cache->get_occupied_byte(cache) + req->obj_size + cache->obj_md_size > cache->cache_size) {
242 cache->evict(cache, req);
243 }
244 cache->insert(cache, req);
245 }
246
247 if (cache->prefetcher && cache->prefetcher->prefetch) {
248 cache->prefetcher->prefetch(cache, req);
249 }
250
251 return hit;
252}
253
254/**
255 * @brief this function is called by all caches to

Callers 15

ARCv0_getFunction · 0.85
LeCaRv0_getFunction · 0.85
LRU_Prob_getFunction · 0.85
nop_getFunction · 0.85
Clock_getFunction · 0.85
FIFO_getFunction · 0.85
S3FIFO_getFunction · 0.85
S3FIFOd_getFunction · 0.85
RandomLRU_getFunction · 0.85
QDLP_getFunction · 0.85
LIRS_getFunction · 0.85
LFUDA_getFunction · 0.85

Calls 4

findMethod · 0.45
updateMethod · 0.45
evictMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected