@@ -20,20 +20,20 @@ extern "C" {
2020#endif
2121
2222typedef struct {
23- cache_t * fifo ;
24- cache_t * fifo_ghost ;
23+ cache_t * small_cache ;
24+ cache_t * ghost_cache ;
2525 cache_t * main_cache ;
2626 bool hit_on_ghost ;
2727
28- int64_t n_obj_admit_to_fifo ;
28+ int64_t n_obj_admit_to_small ;
2929 int64_t n_obj_admit_to_main ;
3030 int64_t n_obj_move_to_main ;
31- int64_t n_byte_admit_to_fifo ;
31+ int64_t n_byte_admit_to_small ;
3232 int64_t n_byte_admit_to_main ;
3333 int64_t n_byte_move_to_main ;
3434
3535 int move_to_main_threshold ;
36- double fifo_size_ratio ;
36+ double small_size_ratio ;
3737 double ghost_size_ratio ;
3838 char main_cache_type [32 ];
3939
@@ -100,22 +100,22 @@ cache_t *QDLP_init(const common_cache_params_t ccache_params,
100100 }
101101
102102 int64_t fifo_cache_size =
103- (int64_t )ccache_params .cache_size * params -> fifo_size_ratio ;
103+ (int64_t )ccache_params .cache_size * params -> small_size_ratio ;
104104 int64_t main_cache_size = ccache_params .cache_size - fifo_cache_size ;
105- int64_t fifo_ghost_cache_size =
105+ int64_t ghost_cache_size =
106106 (int64_t )(ccache_params .cache_size * params -> ghost_size_ratio );
107107
108108 common_cache_params_t ccache_params_local = ccache_params ;
109109 ccache_params_local .cache_size = fifo_cache_size ;
110- params -> fifo = FIFO_init (ccache_params_local , NULL );
110+ params -> small_cache = FIFO_init (ccache_params_local , NULL );
111111
112- if (fifo_ghost_cache_size > 0 ) {
113- ccache_params_local .cache_size = fifo_ghost_cache_size ;
114- params -> fifo_ghost = FIFO_init (ccache_params_local , NULL );
115- snprintf (params -> fifo_ghost -> cache_name , CACHE_NAME_ARRAY_LEN ,
112+ if (ghost_cache_size > 0 ) {
113+ ccache_params_local .cache_size = ghost_cache_size ;
114+ params -> ghost_cache = FIFO_init (ccache_params_local , NULL );
115+ snprintf (params -> ghost_cache -> cache_name , CACHE_NAME_ARRAY_LEN ,
116116 "FIFO-ghost" );
117117 } else {
118- params -> fifo_ghost = NULL ;
118+ params -> ghost_cache = NULL ;
119119 }
120120
121121 ccache_params_local .cache_size = main_cache_size ;
@@ -152,15 +152,15 @@ cache_t *QDLP_init(const common_cache_params_t ccache_params,
152152 }
153153
154154#if defined(TRACK_EVICTION_V_AGE )
155- if (params -> fifo_ghost != NULL ) {
156- params -> fifo_ghost -> track_eviction_age = false;
155+ if (params -> ghost_cache != NULL ) {
156+ params -> ghost -> track_eviction_age = false;
157157 }
158- params -> fifo -> track_eviction_age = false;
158+ params -> small_cache -> track_eviction_age = false;
159159 params -> main_cache -> track_eviction_age = false;
160160#endif
161161
162162 snprintf (cache -> cache_name , CACHE_NAME_ARRAY_LEN , "QDLP-%.4lf-%.4lf-%s-%d" ,
163- params -> fifo_size_ratio , params -> ghost_size_ratio ,
163+ params -> small_size_ratio , params -> ghost_size_ratio ,
164164 params -> main_cache_type , params -> move_to_main_threshold );
165165
166166 return cache ;
@@ -174,9 +174,9 @@ cache_t *QDLP_init(const common_cache_params_t ccache_params,
174174static void QDLP_free (cache_t * cache ) {
175175 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
176176 free_request (params -> req_local );
177- params -> fifo -> cache_free (params -> fifo );
178- if (params -> fifo_ghost != NULL ) {
179- params -> fifo_ghost -> cache_free (params -> fifo_ghost );
177+ params -> small_cache -> cache_free (params -> small_cache );
178+ if (params -> ghost_cache != NULL ) {
179+ params -> ghost_cache -> cache_free (params -> ghost_cache );
180180 }
181181 params -> main_cache -> cache_free (params -> main_cache );
182182 free (cache -> eviction_params );
@@ -204,7 +204,7 @@ static void QDLP_free(cache_t *cache) {
204204 */
205205static bool QDLP_get (cache_t * cache , const request_t * req ) {
206206 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
207- DEBUG_ASSERT (params -> fifo -> get_occupied_byte (params -> fifo ) +
207+ DEBUG_ASSERT (params -> small_cache -> get_occupied_byte (params -> small_cache ) +
208208 params -> main_cache -> get_occupied_byte (params -> main_cache ) <=
209209 cache -> cache_size );
210210
@@ -234,7 +234,7 @@ static cache_obj_t *QDLP_find(cache_t *cache, const request_t *req,
234234
235235 // if update cache is false, we only check the fifo and main caches
236236 if (!update_cache ) {
237- cache_obj_t * obj = params -> fifo -> find (params -> fifo , req , false);
237+ cache_obj_t * obj = params -> small_cache -> find (params -> small_cache , req , false);
238238 if (obj != NULL ) {
239239 return obj ;
240240 }
@@ -247,14 +247,14 @@ static cache_obj_t *QDLP_find(cache_t *cache, const request_t *req,
247247
248248 /* update cache is true from now */
249249 params -> hit_on_ghost = false;
250- cache_obj_t * obj = params -> fifo -> find (params -> fifo , req , true);
250+ cache_obj_t * obj = params -> small_cache -> find (params -> small_cache , req , true);
251251 if (obj != NULL ) {
252252 return obj ;
253253 }
254254
255- if (params -> fifo_ghost != NULL &&
256- params -> fifo_ghost -> remove (params -> fifo_ghost , req -> obj_id )) {
257- // if object in fifo_ghost , remove will return true
255+ if (params -> ghost_cache != NULL &&
256+ params -> ghost_cache -> remove (params -> ghost_cache , req -> obj_id )) {
257+ // if object in ghost , remove will return true
258258 params -> hit_on_ghost = true;
259259 }
260260
@@ -287,12 +287,12 @@ static cache_obj_t *QDLP_insert(cache_t *cache, const request_t *req) {
287287 obj = params -> main_cache -> find (params -> main_cache , req , false);
288288 } else {
289289 /* insert into the fifo */
290- if (req -> obj_size >= params -> fifo -> cache_size ) {
290+ if (req -> obj_size >= params -> small_cache -> cache_size ) {
291291 return NULL ;
292292 }
293- params -> n_obj_admit_to_fifo += 1 ;
294- params -> n_byte_admit_to_fifo += req -> obj_size ;
295- obj = params -> fifo -> insert (params -> fifo , req );
293+ params -> n_obj_admit_to_small += 1 ;
294+ params -> n_byte_admit_to_small += req -> obj_size ;
295+ obj = params -> small_cache -> insert (params -> small_cache , req );
296296 }
297297
298298#if defined(TRACK_EVICTION_V_AGE )
@@ -331,11 +331,11 @@ static cache_obj_t *QDLP_to_evict(cache_t *cache, const request_t *req) {
331331static void QDLP_evict (cache_t * cache , const request_t * req ) {
332332 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
333333
334- cache_t * small_fifo = params -> fifo ;
335- cache_t * ghost_fifo = params -> fifo_ghost ;
334+ cache_t * small_cache = params -> small_cache ;
335+ cache_t * ghost_cache = params -> ghost_cache ;
336336 cache_t * main_cache = params -> main_cache ;
337337
338- if (small_fifo -> get_occupied_byte (small_fifo ) == 0 ) {
338+ if (small_cache -> get_occupied_byte (small_cache ) == 0 ) {
339339#if defined(TRACK_EVICTION_V_AGE )
340340 cache_obj_t * obj = main_cache -> to_evict (main_cache , req );
341341 record_eviction_age (cache , obj , CURR_TIME (cache , req ) - obj -> create_time );
@@ -349,7 +349,7 @@ static void QDLP_evict(cache_t *cache, const request_t *req) {
349349 }
350350
351351 // evict from FIFO
352- cache_obj_t * obj = small_fifo -> to_evict (small_fifo , req );
352+ cache_obj_t * obj = small_cache -> to_evict (small_cache , req );
353353 assert (obj != NULL );
354354 // need to copy the object before it is evicted
355355 copy_cache_obj_to_request (params -> req_local , obj );
@@ -369,14 +369,14 @@ static void QDLP_evict(cache_t *cache, const request_t *req) {
369369 } else {
370370#endif
371371 // insert to ghost
372- if (ghost_fifo != NULL ) {
373- ghost_fifo -> get (ghost_fifo , params -> req_local );
372+ if (ghost_cache != NULL ) {
373+ ghost_cache -> get (ghost_cache , params -> req_local );
374374 }
375375 }
376376
377377 // remove from fifo, but do not update stat
378378 // bool removed = fifo->remove(fifo, params->req_local->obj_id);
379- small_fifo -> evict (small_fifo , req );
379+ small_cache -> evict (small_cache , req );
380380}
381381
382382/**
@@ -395,30 +395,30 @@ static void QDLP_evict(cache_t *cache, const request_t *req) {
395395static bool QDLP_remove (cache_t * cache , const obj_id_t obj_id ) {
396396 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
397397 bool removed = false;
398- removed = removed || params -> fifo -> remove (params -> fifo , obj_id );
399- removed = removed || (params -> fifo_ghost &&
400- params -> fifo_ghost -> remove (params -> fifo_ghost , obj_id ));
398+ removed = removed || params -> small_cache -> remove (params -> small_cache , obj_id );
399+ removed = removed || (params -> ghost_cache &&
400+ params -> ghost_cache -> remove (params -> ghost_cache , obj_id ));
401401 removed = removed || params -> main_cache -> remove (params -> main_cache , obj_id );
402402
403403 return removed ;
404404}
405405
406406static inline int64_t QDLP_get_occupied_byte (const cache_t * cache ) {
407407 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
408- return params -> fifo -> get_occupied_byte (params -> fifo ) +
408+ return params -> small_cache -> get_occupied_byte (params -> small_cache ) +
409409 params -> main_cache -> get_occupied_byte (params -> main_cache );
410410}
411411
412412static inline int64_t QDLP_get_n_obj (const cache_t * cache ) {
413413 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
414- return params -> fifo -> get_n_obj (params -> fifo ) +
414+ return params -> small_cache -> get_n_obj (params -> small_cache ) +
415415 params -> main_cache -> get_n_obj (params -> main_cache );
416416}
417417
418418static inline bool QDLP_can_insert (cache_t * cache , const request_t * req ) {
419419 QDLP_params_t * params = (QDLP_params_t * )cache -> eviction_params ;
420420
421- return req -> obj_size <= params -> fifo -> cache_size &&
421+ return req -> obj_size <= params -> small_cache -> cache_size &&
422422 cache_can_insert_default (cache , req );
423423}
424424
@@ -430,7 +430,7 @@ static inline bool QDLP_can_insert(cache_t *cache, const request_t *req) {
430430static const char * QDLP_current_params (QDLP_params_t * params ) {
431431 static __thread char params_str [128 ];
432432 snprintf (params_str , 128 , "fifo-size-ratio=%.4lf,main-cache=%s\n" ,
433- params -> fifo_size_ratio , params -> main_cache -> cache_name );
433+ params -> small_size_ratio , params -> main_cache -> cache_name );
434434 return params_str ;
435435}
436436
@@ -453,7 +453,7 @@ static void QDLP_parse_params(cache_t *cache,
453453 }
454454
455455 if (strcasecmp (key , "fifo-size-ratio" ) == 0 ) {
456- params -> fifo_size_ratio = strtod (value , NULL );
456+ params -> small_size_ratio = strtod (value , NULL );
457457 } else if (strcasecmp (key , "ghost-size-ratio" ) == 0 ) {
458458 params -> ghost_size_ratio = strtod (value , NULL );
459459 } else if (strcasecmp (key , "move-to-main-threshold" ) == 0 ) {
0 commit comments