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

Function create_cache_with_new_size

libCacheSim/cache/cache.c:115–133  ·  view source on GitHub ↗

* @brief this function is called by all eviction algorithms to clone old cache * with new size * * @param old_cache * @param new_size * @return cache_t* pointer to the new cache */

Source from the content-addressed store, hash-verified

113 * @return cache_t* pointer to the new cache
114 */
115cache_t *create_cache_with_new_size(const cache_t *old_cache, uint64_t new_size) {
116 common_cache_params_t cc_params = {
117 .cache_size = new_size,
118 .hashpower = old_cache->hashtable->hashpower,
119 .default_ttl = old_cache->default_ttl,
120 .consider_obj_metadata = old_cache->obj_md_size == 0 ? false : true,
121 };
122 assert(sizeof(cc_params) == 24);
123 cache_t *cache = old_cache->cache_init(cc_params, old_cache->init_params);
124 if (old_cache->admissioner != NULL) {
125 cache->admissioner = old_cache->admissioner->clone(old_cache->admissioner);
126 }
127 if (old_cache->prefetcher != NULL) {
128 cache->prefetcher = old_cache->prefetcher->clone(old_cache->prefetcher, new_size);
129 }
130 cache->future_stack_dist = old_cache->future_stack_dist;
131 cache->future_stack_dist_array_size = old_cache->future_stack_dist_array_size;
132 return cache;
133}
134
135/**
136 * @brief whether the request can be inserted into cache

Callers 1

simulate_at_multi_sizesFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected