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

Function PG_prefetch

libCacheSim/cache/prefetch/PG.c:156–186  ·  view source on GitHub ↗

prefetch some objects which are from `_PG_get_prefetch_list` @param cache the cache struct @param req the request containing the request @return */

Source from the content-addressed store, hash-verified

154 @return
155 */
156void PG_prefetch(cache_t *cache, const request_t *req) {
157 PG_params_t *PG_params = (PG_params_t *)(cache->prefetcher->params);
158
159 // begin prefetching
160 GList *prefetch_list = _PG_get_prefetch_list(cache, req);
161 if (prefetch_list) {
162 GList *node = prefetch_list;
163 request_t *new_req = my_malloc(request_t);
164 copy_request(new_req, req);
165 while (node) {
166 new_req->obj_id = GPOINTER_TO_INT(node->data);
167 new_req->obj_size =
168 GPOINTER_TO_INT(g_hash_table_lookup(PG_params->cache_size_map, GINT_TO_POINTER(new_req->obj_id)));
169 if (!cache->find(cache, new_req, false)) {
170 while ((long)cache->get_occupied_byte(cache) + new_req->obj_size + cache->obj_md_size >
171 (long)cache->cache_size) {
172 cache->evict(cache, new_req);
173 }
174 cache->insert(cache, new_req);
175
176 PG_params->num_of_prefetch += 1;
177
178 g_hash_table_insert(PG_params->prefetched, GINT_TO_POINTER(new_req->obj_id), GINT_TO_POINTER(1));
179 }
180 node = node->next;
181 }
182
183 my_free(sizeof(request_t), new_req);
184 g_list_free(prefetch_list);
185 }
186}
187
188void free_PG_prefetcher(prefetcher_t *prefetcher) {
189 PG_params_t *PG_params = (PG_params_t *)prefetcher->params;

Callers

nothing calls this directly

Calls 5

_PG_get_prefetch_listFunction · 0.85
copy_requestFunction · 0.85
findMethod · 0.45
evictMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected