-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghost_cache.h
40 lines (32 loc) · 1.04 KB
/
ghost_cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef GHOST_CACHE_H_
#define GHOST_CACHE_H_
#include <inttypes.h>
#include "common.h"
typedef struct GhostCacheEntry {
uint64_t block_num;
uint8_t server_num;
uint8_t volume_num;
uint32_t counter[12];
uint32_t last_access_sub_window_ind;
struct GhostCacheEntry *lookup_prev;
struct GhostCacheEntry *lookup_next;
struct GhostCacheEntry *lru_prev;
struct GhostCacheEntry *lru_next;
}GhostCacheEntry __attribute__((aligned (64)));
typedef struct GhostCache {
uint64_t cache_size;
uint32_t threshold;
uint8_t num_sub_windows;
uint64_t entry_count; // threshold for starting pruning
uint32_t num_inserts;
uint32_t num_replaces;
GhostCacheEntry *cache_entry;
GhostCacheEntry **lookup_table;
GhostCacheEntry *lru_head;
GhostCacheEntry *lru_tail;
}GhostCache;
int ghost_cache_init (uint64_t cache_size, uint32_t threshold,
uint8_t num_sub_windows, GhostCache *cache);
int ghost_cache_access (GhostCache *cache, Request *req);
void ghost_cache_destroy (GhostCache *cache);
#endif