From 8fe5280c5c54e94d4cb45c9accb544e8d75bfcf1 Mon Sep 17 00:00:00 2001 From: Vacantron Chen Date: Sat, 30 Nov 2024 12:18:56 +0800 Subject: [PATCH 1/4] Replace LFU with LRU cache replacement policy The LFU (least-frequently-used) cache replacement policy would be inefficient when the cache is not big enough to hold all translated blocks (IRs). For example, there are two new entries going to be inserted to cache. They would evict each other because the other one has the least used times. This could cause the inefficiency in cache and make the cache-hit ratio fallen. The LRU (least-recently-used) cache replacement policy is more suitable for our needs. However, when the least used cache is evicted from the cache, the counter which is used to trigger JIT compilation is going to be lost. To address this issue, this patch introduces the degenerated adaptive replacement cache (ARC) which has only LRU part and its ghost list. The evicted entries will be temporarily preserved in the ghost list as the history. If the key of inserted entry matches the one in the ghost list, the history will be freed, and the frequency mentioned above would be inherited by the new entry. The performance difference between the original implementation and this patch is shown below: * 1024 entries (10 bits) | Metric | Original | Patched | |-----------|----------------|----------------| | dhrystone | 17720 DMIPS | 17660 DMIPS | | coremark | 5540 iters/s | 5550 iters/s | | aes | 9.164 s | 9.084 s | | nqueens | 1.551 s | 1.493 s | | hamilton | 12.917 s | 12.565 s | * 256 entries (8 bits) | Metric | Original | Patched | |-----------|----------------|----------------| | dhrystone | 17420 DMIPS | 18025 DMIPS | | coremark | 48 iters/s | 5575 iters/s | | aes | 8.904 s | 8.834 s | | nqueens | 6.416 s | 1.348 s | | hamilton | 3400 s | 13.004 s | * 64 entries (6 bits) | Metric | Original | Patched | |-----------|----------------|----------------| | dhrystone | 17720 DMIPS | 17850 DMIPS | | coremark | (timeout) | 215 iters/s | | aes | 342 s | 8.882 s | | nqueens | 680 s | 1.506 s | | hamilton | (timeout) | 13.724 s | * Experimental Linux Kernel booting: 126s (original) -> 21s (patched) --- mk/tests.mk | 8 +- src/cache.c | 284 ++++-- src/cache.h | 2 +- src/emulate.c | 9 +- tests/cache/cache-get.expect | 8 +- tests/cache/{lfu => }/cache-get.in | 2 + tests/cache/cache-lfu-ghost-replace.expect | 773 --------------- tests/cache/cache-lfu-replace.expect | 515 ---------- tests/cache/cache-lru-ghost-replace.expect | 261 ----- tests/cache/cache-lru-replace.expect | 3 - tests/cache/{lfu => }/cache-new.in | 0 tests/cache/cache-put.in | 19 + tests/cache/cache-replace.expect | 62 ++ tests/cache/cache-replace.in | 78 ++ tests/cache/lfu/cache-get.expect | 5 - tests/cache/lfu/cache-lfu-replace.expect | 771 --------------- tests/cache/lfu/cache-lfu-replace.in | 1027 -------------------- tests/cache/lfu/cache-new.expect | 2 - tests/cache/lfu/cache-put.expect | 3 - tests/cache/lfu/cache-put.in | 259 ----- tests/cache/test-cache.c | 30 +- 21 files changed, 377 insertions(+), 3744 deletions(-) rename tests/cache/{lfu => }/cache-get.in (74%) delete mode 100644 tests/cache/cache-lfu-ghost-replace.expect delete mode 100644 tests/cache/cache-lfu-replace.expect delete mode 100644 tests/cache/cache-lru-ghost-replace.expect delete mode 100644 tests/cache/cache-lru-replace.expect rename tests/cache/{lfu => }/cache-new.in (100%) create mode 100644 tests/cache/cache-put.in create mode 100644 tests/cache/cache-replace.expect create mode 100644 tests/cache/cache-replace.in delete mode 100644 tests/cache/lfu/cache-get.expect delete mode 100644 tests/cache/lfu/cache-lfu-replace.expect delete mode 100644 tests/cache/lfu/cache-lfu-replace.in delete mode 100644 tests/cache/lfu/cache-new.expect delete mode 100644 tests/cache/lfu/cache-put.expect delete mode 100644 tests/cache/lfu/cache-put.in diff --git a/mk/tests.mk b/mk/tests.mk index a75d6aa7..77eeb0ed 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -36,10 +36,10 @@ OBJS += $(PATH_TEST_OBJS) deps += $(PATH_TEST_OBJS:%.o=%.o.d) CACHE_TEST_ACTIONS := \ - lfu/cache-new \ - lfu/cache-put \ - lfu/cache-get \ - lfu/cache-lfu-replace + cache-new \ + cache-put \ + cache-get \ + cache-replace CACHE_TEST_OUT = $(addprefix $(CACHE_TEST_OUTDIR)/, $(CACHE_TEST_ACTIONS:%=%.out)) MAP_TEST_OUT = $(MAP_TEST_TARGET).out diff --git a/src/cache.c b/src/cache.c index 38dcaae3..4a07fe91 100644 --- a/src/cache.c +++ b/src/cache.c @@ -15,7 +15,6 @@ #include "utils.h" static uint32_t cache_size, cache_size_bits; -static struct mpool *cache_mp; /* hash function for the cache */ HASH_FUNC_IMPL(cache_hash, cache_size_bits, cache_size) @@ -30,20 +29,35 @@ struct hlist_node { typedef struct { void *value; + bool alive; /* indicates whether this cache is alive or a history of evicted + cache in hash map */ uint32_t key; - uint32_t frequency; + uint32_t freq; struct list_head list; struct hlist_node ht_list; -} lfu_entry_t; +} cache_entry_t; typedef struct { struct hlist_head *ht_list_head; } hashtable_t; +/* + * The cache utilizes the degenerated adaptive replacement cache (ARC), which + * has only least-recently-used (LRU) and ignores least-frequently-used (LFU) + * part. The frequently used cache will be compiled to the binary of target + * platform by the just-in-time (JIT) compiler, so that it doesn't need to be + * preserved in cache anymore. When the cache is full, the least used cache is + * going to be evicted to the ghost list as the history. If the key of the + * inserted entry matches the one in the ghost list, the history will be + * detached and freed, and the stored information will be inherited by the new + * entry. + */ typedef struct cache { - struct list_head *lists[THRESHOLD]; - uint32_t list_size; - hashtable_t *map; + struct list_head list; /* list of live cache */ + struct list_head ghost_list; /* list of evicted cache */ + hashtable_t map; /* hash map which contains both live and evicted cache */ + uint32_t size; + uint32_t ghost_list_size; uint32_t capacity; } cache_t; @@ -107,105 +121,142 @@ static inline void hlist_del_init(struct hlist_node *n) (ptr) ? hlist_entry(ptr, type, member) : NULL #endif +/* clang-format off */ #ifdef __HAVE_TYPEOF #define hlist_for_each_entry(pos, head, member) \ for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); pos; \ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) + +#define hlist_for_each_entry_safe(pos, n, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \ + pos && ({ n = pos->member.next; 1; }); \ + pos = hlist_entry_safe(n, typeof(*pos), member)) #else #define hlist_for_each_entry(pos, head, member, type) \ for (pos = hlist_entry_safe((head)->first, type, member); pos; \ pos = hlist_entry_safe((pos)->member.next, type, member)) + +#define hlist_for_each_entry_safe(pos, n, head, member, type) \ + for (pos = hlist_entry_safe((head)->first, type, member); \ + pos && ({ n = pos->member.next; 1; }); \ + pos = hlist_entry_safe(n, type, member)) #endif +/* clang-format on */ -cache_t *cache_create(int size_bits) +cache_t *cache_create(uint32_t size_bits) { - int i; cache_t *cache = malloc(sizeof(cache_t)); if (!cache) return NULL; cache_size_bits = size_bits; cache_size = 1 << size_bits; - for (i = 0; i < THRESHOLD; i++) { - cache->lists[i] = malloc(sizeof(struct list_head)); - if (!cache->lists[i]) - goto free_lists; - INIT_LIST_HEAD(cache->lists[i]); - } - - cache->map = malloc(sizeof(hashtable_t)); - if (!cache->map) - goto free_lists; - cache->map->ht_list_head = malloc(cache_size * sizeof(struct hlist_head)); - if (!cache->map->ht_list_head) - goto free_map; - - for (size_t ii = 0; ii < cache_size; ii++) - INIT_HLIST_HEAD(&cache->map->ht_list_head[ii]); - cache->list_size = 0; - cache_mp = - mpool_create(cache_size * sizeof(lfu_entry_t), sizeof(lfu_entry_t)); + INIT_LIST_HEAD(&cache->list); + INIT_LIST_HEAD(&cache->ghost_list); + cache->size = 0; + cache->ghost_list_size = 0; cache->capacity = cache_size; - return cache; -free_map: - free(cache->map); -free_lists: - for (int j = 0; j < i; j++) - free(cache->lists[j]); + cache->map.ht_list_head = malloc(cache_size * sizeof(struct hlist_head)); + if (!cache->map.ht_list_head) { + free(cache); + return NULL; + } - free(cache); - return NULL; + for (uint32_t i = 0; i < cache_size; i++) + INIT_HLIST_HEAD(&cache->map.ht_list_head[i]); + + return cache; } void *cache_get(const cache_t *cache, uint32_t key, bool update) { - if (!cache->capacity || - hlist_empty(&cache->map->ht_list_head[cache_hash(key)])) + if (unlikely(!cache->capacity)) + return NULL; + + if (hlist_empty(&cache->map.ht_list_head[cache_hash(key)])) return NULL; - lfu_entry_t *entry = NULL; + cache_entry_t *entry = NULL; #ifdef __HAVE_TYPEOF - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], ht_list) #else - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], - ht_list, lfu_entry_t) + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], + ht_list, cache_entry_t) #endif { if (entry->key == key) break; } - if (!entry || entry->key != key) + + /* return NULL if cache miss */ + if (!entry || entry->key != key || !entry->alive) return NULL; + /* + * FIXME: In system simulation, there might be several identical PC from + * different processes. We need to check the SATP CSR to update the correct + * entry. + */ /* When the frequency of use for a specific block exceeds the predetermined * THRESHOLD, the block is dispatched to the code generator to generate C * code. The generated C code is then compiled into machine code by the * target compiler. */ - if (update && entry->frequency < THRESHOLD) { - list_del_init(&entry->list); - list_add(&entry->list, cache->lists[entry->frequency++]); - } + if (update) + entry->freq++; - /* return NULL if cache miss */ return entry->value; } +/* + * When the size of ghost list reaches the limit, the oldest history is going to + * be dropped. The stored information will be lost forever. + */ +FORCE_INLINE void cache_ghost_list_update(cache_t *cache) +{ + if (cache->ghost_list_size <= cache->capacity) + return; + + cache_entry_t *entry = + list_last_entry(&cache->ghost_list, cache_entry_t, list); + assert(!entry->alive); + hlist_del_init(&entry->ht_list); + list_del_init(&entry->list); + cache->ghost_list_size--; + free(entry); +} + +/* + * For a cache insertion, it might be the one which: + * - evicts the least recently used cache + * - updates the existing cache + * - retrieves the information from the history in the glost list + */ void *cache_put(cache_t *cache, uint32_t key, void *value) { - assert(cache->list_size <= cache->capacity); + assert(cache->size <= cache->capacity); - lfu_entry_t *replaced_entry = NULL, *entry; - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], - ht_list) { + cache_entry_t *replaced = NULL, *revived = NULL, *entry; +#ifdef __HAVE_TYPEOF + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], + ht_list) +#else + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], + ht_list, cache_entry_t) +#endif + { if (entry->key != key) continue; + if (!entry->alive) { + revived = entry; + break; + } /* update the existing cache */ if (entry->value != value) { - replaced_entry = entry; + replaced = entry; break; } /* should not put an identical block to cache */ @@ -214,67 +265,80 @@ void *cache_put(cache_t *cache, uint32_t key, void *value) } /* get the entry to be replaced if cache is full */ - if (!replaced_entry && cache->list_size == cache->capacity) { - for (int i = 0; i < THRESHOLD; i++) { - if (list_empty(cache->lists[i])) - continue; - replaced_entry = - list_last_entry(cache->lists[i], lfu_entry_t, list); - break; - } - assert(replaced_entry); + if (!replaced && cache->size == cache->capacity) { + replaced = list_last_entry(&cache->list, cache_entry_t, list); + assert(replaced); } void *replaced_value = NULL; - if (replaced_entry) { - replaced_value = replaced_entry->value; - list_del_init(&replaced_entry->list); - hlist_del_init(&replaced_entry->ht_list); - mpool_free(cache_mp, replaced_entry); - cache->list_size--; + if (replaced) { + assert(replaced->alive); + + replaced_value = replaced->value; + replaced->alive = false; + list_del_init(&replaced->list); + cache->size--; + list_add(&replaced->list, &cache->ghost_list); + cache->ghost_list_size++; } - lfu_entry_t *new_entry = mpool_alloc(cache_mp); + cache_entry_t *new_entry = calloc(1, sizeof(cache_entry_t)); + assert(new_entry); + INIT_LIST_HEAD(&new_entry->list); INIT_HLIST_NODE(&new_entry->ht_list); new_entry->key = key; new_entry->value = value; - new_entry->frequency = 0; - list_add(&new_entry->list, cache->lists[new_entry->frequency++]); + new_entry->alive = true; + + if (!revived) { + new_entry->freq = 1; + } else { + new_entry->freq = revived->freq + 1; + hlist_del_init(&revived->ht_list); + list_del_init(&revived->list); + cache->ghost_list_size--; + free(revived); + } + + list_add(&new_entry->list, &cache->list); hlist_add_head(&new_entry->ht_list, - &cache->map->ht_list_head[cache_hash(key)]); - cache->list_size++; + &cache->map.ht_list_head[cache_hash(key)]); + + cache->size++; - assert(cache->list_size <= cache->capacity); + cache_ghost_list_update(cache); + + assert(cache->size <= cache->capacity); + assert(cache->ghost_list_size <= cache->capacity); return replaced_value; } void cache_free(cache_t *cache) { - for (int i = 0; i < THRESHOLD; i++) - free(cache->lists[i]); - mpool_destroy(cache_mp); - free(cache->map->ht_list_head); - free(cache->map); + free(cache->map.ht_list_head); free(cache); } uint32_t cache_freq(const struct cache *cache, uint32_t key) { - if (!cache->capacity || - hlist_empty(&cache->map->ht_list_head[cache_hash(key)])) + if (unlikely(!cache->capacity)) + return 0; + + if (hlist_empty(&cache->map.ht_list_head[cache_hash(key)])) return 0; - lfu_entry_t *entry = NULL; + + cache_entry_t *entry = NULL; #ifdef __HAVE_TYPEOF - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], ht_list) #else - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], - ht_list, lfu_entry_t) + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], + ht_list, cache_entry_t) #endif { - if (entry->key == key) - return entry->frequency; + if (entry->key == key && entry->alive) + return entry->freq; } return 0; } @@ -282,20 +346,24 @@ uint32_t cache_freq(const struct cache *cache, uint32_t key) #if RV32_HAS(JIT) bool cache_hot(const struct cache *cache, uint32_t key) { - if (!cache->capacity || - hlist_empty(&cache->map->ht_list_head[cache_hash(key)])) + if (unlikely(!cache->capacity)) + return false; + + if (hlist_empty(&cache->map.ht_list_head[cache_hash(key)])) return false; - lfu_entry_t *entry = NULL; + + cache_entry_t *entry = NULL; #ifdef __HAVE_TYPEOF - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], ht_list) #else - hlist_for_each_entry (entry, &cache->map->ht_list_head[cache_hash(key)], - ht_list, lfu_entry_t) + hlist_for_each_entry (entry, &cache->map.ht_list_head[cache_hash(key)], + ht_list, cache_entry_t) #endif { - if (entry->key == key && entry->frequency == THRESHOLD) + if (entry->key == key && entry->alive && entry->freq >= THRESHOLD) { return true; + } } return false; } @@ -303,12 +371,18 @@ void cache_profile(const struct cache *cache, FILE *output_file, prof_func_t func) { + assert(cache); assert(func); - for (int i = 0; i < THRESHOLD; i++) { - lfu_entry_t *entry, *safe; - list_for_each_entry_safe (entry, safe, cache->lists[i], list) { - func(entry->value, entry->frequency, output_file); - } + assert(output_file); + + cache_entry_t *entry; +#ifdef __HAVE_TYPEOF + list_for_each_entry (entry, &cache->list, list) +#else + list_for_each_entry (entry, &cache->list, list, cache_entry_t) +#endif + { + func(entry->value, entry->freq, output_file); } } @@ -316,11 +390,15 @@ void clear_cache_hot(const struct cache *cache, clear_func_t func) { assert(cache); assert(func); - for (int i = 0; i < THRESHOLD; i++) { - lfu_entry_t *entry, *safe; - list_for_each_entry_safe (entry, safe, cache->lists[i], list) { - func(entry->value); - } + + cache_entry_t *entry = NULL; +#ifdef __HAVE_TYPEOF + list_for_each_entry (entry, &cache->list, list) +#else + list_for_each_entry (entry, &cache->list, list, cache_entry_t) +#endif + { + func(entry->value); } } #endif diff --git a/src/cache.h b/src/cache.h index 9d9e87f5..f6b76ea1 100644 --- a/src/cache.h +++ b/src/cache.h @@ -21,7 +21,7 @@ struct cache; * @size_bits: cache size is 2^size_bits * @return: a pointer points to new cache */ -struct cache *cache_create(int size_bits); +struct cache *cache_create(uint32_t size_bits); /** * cache_get - retrieve the specified entry from the cache diff --git a/src/emulate.c b/src/emulate.c index a7dcced9..4dca078d 100644 --- a/src/emulate.c +++ b/src/emulate.c @@ -833,7 +833,7 @@ static block_t *block_find_or_translate(riscv_t *rv) list_add(&next_blk->list, &rv->block_list); /* insert the block into block cache */ - block_t *replaced_blk = cache_put(rv->block_cache, rv->PC, &(*next_blk)); + block_t *replaced_blk = cache_put(rv->block_cache, rv->PC, next_blk); if (!replaced_blk) return next_blk; @@ -891,7 +891,7 @@ static bool runtime_profiler(riscv_t *rv, block_t *block) if (unlikely(freq >= 2 && block->has_loops)) return true; /* using frequency exceeds predetermined threshold */ - if (unlikely(freq == THRESHOLD)) + if (unlikely(freq >= THRESHOLD)) return true; return false; } @@ -966,6 +966,11 @@ void rv_step(void *arg) #endif /* executed through the tier-1 JIT compiler */ struct jit_state *state = rv->jit_state; + /* + * TODO: We do not explicitly need the translated block. We only need + * the program counter as a key for searching the corresponding + * entry in compiled binary buffer. + */ if (block->hot) { block->n_invoke++; ((exec_block_func_t) state->buf)( diff --git a/tests/cache/cache-get.expect b/tests/cache/cache-get.expect index 3c48e062..2cda9389 100644 --- a/tests/cache/cache-get.expect +++ b/tests/cache/cache-get.expect @@ -1,5 +1,7 @@ NEW CACHE -NULL -NULL -3 +NULL 0 +NULL 0 +3 2 +3 3 +3 4 FREE CACHE diff --git a/tests/cache/lfu/cache-get.in b/tests/cache/cache-get.in similarity index 74% rename from tests/cache/lfu/cache-get.in rename to tests/cache/cache-get.in index f7a37f56..f45e2928 100644 --- a/tests/cache/lfu/cache-get.in +++ b/tests/cache/cache-get.in @@ -3,4 +3,6 @@ GET 1 GET 2 PUT 3 3 GET 3 +GET 3 +GET 3 FREE diff --git a/tests/cache/cache-lfu-ghost-replace.expect b/tests/cache/cache-lfu-ghost-replace.expect deleted file mode 100644 index 3a38754b..00000000 --- a/tests/cache/cache-lfu-ghost-replace.expect +++ /dev/null @@ -1,773 +0,0 @@ -NEW CACHE -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 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -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 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431 -432 -433 -434 -435 -436 -437 -438 -439 -440 -441 -442 -443 -444 -445 -446 -447 -448 -449 -450 -451 -452 -453 -454 -455 -456 -457 -458 -459 -460 -461 -462 -463 -464 -465 -466 -467 -468 -469 -470 -471 -472 -473 -474 -475 -476 -477 -478 -479 -480 -481 -482 -483 -484 -485 -486 -487 -488 -489 -490 -491 -492 -493 -494 -495 -496 -497 -498 -499 -500 -501 -502 -503 -504 -505 -506 -507 -508 -509 -510 -511 -512 -REPLACE 1 -FREE CACHE diff --git a/tests/cache/cache-lfu-replace.expect b/tests/cache/cache-lfu-replace.expect deleted file mode 100644 index 00f32a3f..00000000 --- a/tests/cache/cache-lfu-replace.expect +++ /dev/null @@ -1,515 +0,0 @@ -NEW CACHE -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 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431 -432 -433 -434 -435 -436 -437 -438 -439 -440 -441 -442 -443 -444 -445 -446 -447 -448 -449 -450 -451 -452 -453 -454 -455 -456 -457 -458 -459 -460 -461 -462 -463 -464 -465 -466 -467 -468 -469 -470 -471 -472 -473 -474 -475 -476 -477 -478 -479 -480 -481 -482 -483 -484 -485 -486 -487 -488 -489 -490 -491 -492 -493 -494 -495 -496 -497 -498 -499 -500 -501 -502 -503 -504 -505 -506 -507 -508 -509 -510 -511 -512 -REPLACE 1 -FREE CACHE diff --git a/tests/cache/cache-lru-ghost-replace.expect b/tests/cache/cache-lru-ghost-replace.expect deleted file mode 100644 index 9fffae59..00000000 --- a/tests/cache/cache-lru-ghost-replace.expect +++ /dev/null @@ -1,261 +0,0 @@ -NEW CACHE -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 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -REPLACE 257 -FREE CACHE diff --git a/tests/cache/cache-lru-replace.expect b/tests/cache/cache-lru-replace.expect deleted file mode 100644 index eae31924..00000000 --- a/tests/cache/cache-lru-replace.expect +++ /dev/null @@ -1,3 +0,0 @@ -NEW CACHE -REPLACE 1 -FREE CACHE diff --git a/tests/cache/lfu/cache-new.in b/tests/cache/cache-new.in similarity index 100% rename from tests/cache/lfu/cache-new.in rename to tests/cache/cache-new.in diff --git a/tests/cache/cache-put.in b/tests/cache/cache-put.in new file mode 100644 index 00000000..13b1d4ed --- /dev/null +++ b/tests/cache/cache-put.in @@ -0,0 +1,19 @@ +NEW +PUT 1 1 +PUT 2 2 +PUT 3 3 +PUT 4 4 +PUT 5 5 +PUT 6 6 +PUT 7 7 +PUT 8 8 +PUT 9 9 +PUT 10 10 +PUT 11 11 +PUT 12 12 +PUT 13 13 +PUT 14 14 +PUT 15 15 +PUT 16 16 +PUT 17 17 +FREE diff --git a/tests/cache/cache-replace.expect b/tests/cache/cache-replace.expect new file mode 100644 index 00000000..50163bbf --- /dev/null +++ b/tests/cache/cache-replace.expect @@ -0,0 +1,62 @@ +NEW CACHE +REPLACE 1 +REPLACE 2 +REPLACE 3 +REPLACE 4 +REPLACE 5 +REPLACE 6 +REPLACE 7 +REPLACE 8 +REPLACE 9 +25 3 +REPLACE 10 +26 3 +REPLACE 11 +27 3 +REPLACE 12 +28 3 +REPLACE 13 +REPLACE 14 +REPLACE 15 +REPLACE 16 +REPLACE 17 +REPLACE 18 +REPLACE 19 +REPLACE 20 +REPLACE 21 +REPLACE 22 +REPLACE 23 +REPLACE 24 +REPLACE 25 +REPLACE 26 +REPLACE 27 +REPLACE 28 +REPLACE 29 +REPLACE 30 +REPLACE 31 +REPLACE 32 +REPLACE 33 +REPLACE 34 +REPLACE 35 +REPLACE 36 +REPLACE 37 +REPLACE 38 +REPLACE 39 +REPLACE 40 +REPLACE 41 +REPLACE 42 +REPLACE 43 +REPLACE 44 +REPLACE 45 +REPLACE 46 +REPLACE 47 +REPLACE 48 +REPLACE 49 +65 2 +REPLACE 50 +66 2 +REPLACE 51 +67 2 +REPLACE 52 +68 2 +FREE CACHE diff --git a/tests/cache/cache-replace.in b/tests/cache/cache-replace.in new file mode 100644 index 00000000..bb46698e --- /dev/null +++ b/tests/cache/cache-replace.in @@ -0,0 +1,78 @@ +NEW +PUT 1 1 +PUT 2 2 +PUT 3 3 +PUT 4 4 +PUT 5 5 +PUT 6 6 +PUT 7 7 +PUT 8 8 +PUT 9 9 +PUT 10 10 +PUT 11 11 +PUT 12 12 +PUT 13 13 +PUT 14 14 +PUT 15 15 +PUT 16 16 +PUT 17 17 +PUT 18 18 +PUT 19 19 +PUT 20 20 +PUT 21 21 +PUT 22 22 +PUT 23 23 +PUT 24 24 +PUT 1 25 +GET 1 +PUT 2 26 +GET 2 +PUT 3 27 +GET 3 +PUT 4 28 +GET 4 +PUT 29 29 +PUT 30 30 +PUT 31 31 +PUT 32 32 +PUT 33 33 +PUT 34 34 +PUT 35 35 +PUT 36 36 +PUT 37 37 +PUT 38 38 +PUT 39 39 +PUT 40 40 +PUT 41 41 +PUT 42 42 +PUT 43 43 +PUT 44 44 +PUT 45 45 +PUT 46 46 +PUT 47 47 +PUT 48 48 +PUT 49 49 +PUT 50 50 +PUT 51 51 +PUT 52 52 +PUT 53 53 +PUT 54 54 +PUT 55 55 +PUT 56 56 +PUT 57 57 +PUT 58 58 +PUT 59 59 +PUT 60 60 +PUT 61 61 +PUT 62 62 +PUT 63 63 +PUT 64 64 +PUT 5 65 +GET 5 +PUT 6 66 +GET 6 +PUT 7 67 +GET 7 +PUT 8 68 +GET 8 +FREE diff --git a/tests/cache/lfu/cache-get.expect b/tests/cache/lfu/cache-get.expect deleted file mode 100644 index 3c48e062..00000000 --- a/tests/cache/lfu/cache-get.expect +++ /dev/null @@ -1,5 +0,0 @@ -NEW CACHE -NULL -NULL -3 -FREE CACHE diff --git a/tests/cache/lfu/cache-lfu-replace.expect b/tests/cache/lfu/cache-lfu-replace.expect deleted file mode 100644 index 60a8637b..00000000 --- a/tests/cache/lfu/cache-lfu-replace.expect +++ /dev/null @@ -1,771 +0,0 @@ -NEW CACHE -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 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -REPLACE 1 -REPLACE 257 -REPLACE 258 -REPLACE 259 -REPLACE 260 -REPLACE 261 -REPLACE 262 -REPLACE 263 -REPLACE 264 -REPLACE 265 -REPLACE 266 -REPLACE 267 -REPLACE 268 -REPLACE 269 -REPLACE 270 -REPLACE 271 -REPLACE 272 -REPLACE 273 -REPLACE 274 -REPLACE 275 -REPLACE 276 -REPLACE 277 -REPLACE 278 -REPLACE 279 -REPLACE 280 -REPLACE 281 -REPLACE 282 -REPLACE 283 -REPLACE 284 -REPLACE 285 -REPLACE 286 -REPLACE 287 -REPLACE 288 -REPLACE 289 -REPLACE 290 -REPLACE 291 -REPLACE 292 -REPLACE 293 -REPLACE 294 -REPLACE 295 -REPLACE 296 -REPLACE 297 -REPLACE 298 -REPLACE 299 -REPLACE 300 -REPLACE 301 -REPLACE 302 -REPLACE 303 -REPLACE 304 -REPLACE 305 -REPLACE 306 -REPLACE 307 -REPLACE 308 -REPLACE 309 -REPLACE 310 -REPLACE 311 -REPLACE 312 -REPLACE 313 -REPLACE 314 -REPLACE 315 -REPLACE 316 -REPLACE 317 -REPLACE 318 -REPLACE 319 -REPLACE 320 -REPLACE 321 -REPLACE 322 -REPLACE 323 -REPLACE 324 -REPLACE 325 -REPLACE 326 -REPLACE 327 -REPLACE 328 -REPLACE 329 -REPLACE 330 -REPLACE 331 -REPLACE 332 -REPLACE 333 -REPLACE 334 -REPLACE 335 -REPLACE 336 -REPLACE 337 -REPLACE 338 -REPLACE 339 -REPLACE 340 -REPLACE 341 -REPLACE 342 -REPLACE 343 -REPLACE 344 -REPLACE 345 -REPLACE 346 -REPLACE 347 -REPLACE 348 -REPLACE 349 -REPLACE 350 -REPLACE 351 -REPLACE 352 -REPLACE 353 -REPLACE 354 -REPLACE 355 -REPLACE 356 -REPLACE 357 -REPLACE 358 -REPLACE 359 -REPLACE 360 -REPLACE 361 -REPLACE 362 -REPLACE 363 -REPLACE 364 -REPLACE 365 -REPLACE 366 -REPLACE 367 -REPLACE 368 -REPLACE 369 -REPLACE 370 -REPLACE 371 -REPLACE 372 -REPLACE 373 -REPLACE 374 -REPLACE 375 -REPLACE 376 -REPLACE 377 -REPLACE 378 -REPLACE 379 -REPLACE 380 -REPLACE 381 -REPLACE 382 -REPLACE 383 -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -384 -REPLACE 2 -REPLACE 385 -REPLACE 386 -REPLACE 387 -REPLACE 388 -REPLACE 389 -REPLACE 390 -REPLACE 391 -REPLACE 392 -REPLACE 393 -REPLACE 394 -REPLACE 395 -REPLACE 396 -REPLACE 397 -REPLACE 398 -REPLACE 399 -REPLACE 400 -REPLACE 401 -REPLACE 402 -REPLACE 403 -REPLACE 404 -REPLACE 405 -REPLACE 406 -REPLACE 407 -REPLACE 408 -REPLACE 409 -REPLACE 410 -REPLACE 411 -REPLACE 412 -REPLACE 413 -REPLACE 414 -REPLACE 415 -REPLACE 416 -REPLACE 417 -REPLACE 418 -REPLACE 419 -REPLACE 420 -REPLACE 421 -REPLACE 422 -REPLACE 423 -REPLACE 424 -REPLACE 425 -REPLACE 426 -REPLACE 427 -REPLACE 428 -REPLACE 429 -REPLACE 430 -REPLACE 431 -REPLACE 432 -REPLACE 433 -REPLACE 434 -REPLACE 435 -REPLACE 436 -REPLACE 437 -REPLACE 438 -REPLACE 439 -REPLACE 440 -REPLACE 441 -REPLACE 442 -REPLACE 443 -REPLACE 444 -REPLACE 445 -REPLACE 446 -REPLACE 447 -REPLACE 448 -REPLACE 449 -REPLACE 450 -REPLACE 451 -REPLACE 452 -REPLACE 453 -REPLACE 454 -REPLACE 455 -REPLACE 456 -REPLACE 457 -REPLACE 458 -REPLACE 459 -REPLACE 460 -REPLACE 461 -REPLACE 462 -REPLACE 463 -REPLACE 464 -REPLACE 465 -REPLACE 466 -REPLACE 467 -REPLACE 468 -REPLACE 469 -REPLACE 470 -REPLACE 471 -REPLACE 472 -REPLACE 473 -REPLACE 474 -REPLACE 475 -REPLACE 476 -REPLACE 477 -REPLACE 478 -REPLACE 479 -REPLACE 480 -REPLACE 481 -REPLACE 482 -REPLACE 483 -REPLACE 484 -REPLACE 485 -REPLACE 486 -REPLACE 487 -REPLACE 488 -REPLACE 489 -REPLACE 490 -REPLACE 491 -REPLACE 492 -REPLACE 493 -REPLACE 494 -REPLACE 495 -REPLACE 496 -REPLACE 497 -REPLACE 498 -REPLACE 499 -REPLACE 500 -REPLACE 501 -REPLACE 502 -REPLACE 503 -REPLACE 504 -REPLACE 505 -REPLACE 506 -REPLACE 507 -REPLACE 508 -REPLACE 509 -REPLACE 510 -REPLACE 511 -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -512 -REPLACE 3 -FREE CACHE diff --git a/tests/cache/lfu/cache-lfu-replace.in b/tests/cache/lfu/cache-lfu-replace.in deleted file mode 100644 index b5560d36..00000000 --- a/tests/cache/lfu/cache-lfu-replace.in +++ /dev/null @@ -1,1027 +0,0 @@ -NEW -PUT 1 1 -PUT 2 2 -PUT 3 3 -PUT 4 4 -PUT 5 5 -PUT 6 6 -PUT 7 7 -PUT 8 8 -PUT 9 9 -PUT 10 10 -PUT 11 11 -PUT 12 12 -PUT 13 13 -PUT 14 14 -PUT 15 15 -PUT 16 16 -PUT 17 17 -PUT 18 18 -PUT 19 19 -PUT 20 20 -PUT 21 21 -PUT 22 22 -PUT 23 23 -PUT 24 24 -PUT 25 25 -PUT 26 26 -PUT 27 27 -PUT 28 28 -PUT 29 29 -PUT 30 30 -PUT 31 31 -PUT 32 32 -PUT 33 33 -PUT 34 34 -PUT 35 35 -PUT 36 36 -PUT 37 37 -PUT 38 38 -PUT 39 39 -PUT 40 40 -PUT 41 41 -PUT 42 42 -PUT 43 43 -PUT 44 44 -PUT 45 45 -PUT 46 46 -PUT 47 47 -PUT 48 48 -PUT 49 49 -PUT 50 50 -PUT 51 51 -PUT 52 52 -PUT 53 53 -PUT 54 54 -PUT 55 55 -PUT 56 56 -PUT 57 57 -PUT 58 58 -PUT 59 59 -PUT 60 60 -PUT 61 61 -PUT 62 62 -PUT 63 63 -PUT 64 64 -PUT 65 65 -PUT 66 66 -PUT 67 67 -PUT 68 68 -PUT 69 69 -PUT 70 70 -PUT 71 71 -PUT 72 72 -PUT 73 73 -PUT 74 74 -PUT 75 75 -PUT 76 76 -PUT 77 77 -PUT 78 78 -PUT 79 79 -PUT 80 80 -PUT 81 81 -PUT 82 82 -PUT 83 83 -PUT 84 84 -PUT 85 85 -PUT 86 86 -PUT 87 87 -PUT 88 88 -PUT 89 89 -PUT 90 90 -PUT 91 91 -PUT 92 92 -PUT 93 93 -PUT 94 94 -PUT 95 95 -PUT 96 96 -PUT 97 97 -PUT 98 98 -PUT 99 99 -PUT 100 100 -PUT 101 101 -PUT 102 102 -PUT 103 103 -PUT 104 104 -PUT 105 105 -PUT 106 106 -PUT 107 107 -PUT 108 108 -PUT 109 109 -PUT 110 110 -PUT 111 111 -PUT 112 112 -PUT 113 113 -PUT 114 114 -PUT 115 115 -PUT 116 116 -PUT 117 117 -PUT 118 118 -PUT 119 119 -PUT 120 120 -PUT 121 121 -PUT 122 122 -PUT 123 123 -PUT 124 124 -PUT 125 125 -PUT 126 126 -PUT 127 127 -PUT 128 128 -GET 1 -GET 2 -GET 3 -GET 4 -GET 5 -GET 6 -GET 7 -GET 8 -GET 9 -GET 10 -GET 11 -GET 12 -GET 13 -GET 14 -GET 15 -GET 16 -GET 17 -GET 18 -GET 19 -GET 20 -GET 21 -GET 22 -GET 23 -GET 24 -GET 25 -GET 26 -GET 27 -GET 28 -GET 29 -GET 30 -GET 31 -GET 32 -GET 33 -GET 34 -GET 35 -GET 36 -GET 37 -GET 38 -GET 39 -GET 40 -GET 41 -GET 42 -GET 43 -GET 44 -GET 45 -GET 46 -GET 47 -GET 48 -GET 49 -GET 50 -GET 51 -GET 52 -GET 53 -GET 54 -GET 55 -GET 56 -GET 57 -GET 58 -GET 59 -GET 60 -GET 61 -GET 62 -GET 63 -GET 64 -GET 65 -GET 66 -GET 67 -GET 68 -GET 69 -GET 70 -GET 71 -GET 72 -GET 73 -GET 74 -GET 75 -GET 76 -GET 77 -GET 78 -GET 79 -GET 80 -GET 81 -GET 82 -GET 83 -GET 84 -GET 85 -GET 86 -GET 87 -GET 88 -GET 89 -GET 90 -GET 91 -GET 92 -GET 93 -GET 94 -GET 95 -GET 96 -GET 97 -GET 98 -GET 99 -GET 100 -GET 101 -GET 102 -GET 103 -GET 104 -GET 105 -GET 106 -GET 107 -GET 108 -GET 109 -GET 110 -GET 111 -GET 112 -GET 113 -GET 114 -GET 115 -GET 116 -GET 117 -GET 118 -GET 119 -GET 120 -GET 121 -GET 122 -GET 123 -GET 124 -GET 125 -GET 126 -GET 127 -GET 128 -PUT 129 129 -PUT 130 130 -PUT 131 131 -PUT 132 132 -PUT 133 133 -PUT 134 134 -PUT 135 135 -PUT 136 136 -PUT 137 137 -PUT 138 138 -PUT 139 139 -PUT 140 140 -PUT 141 141 -PUT 142 142 -PUT 143 143 -PUT 144 144 -PUT 145 145 -PUT 146 146 -PUT 147 147 -PUT 148 148 -PUT 149 149 -PUT 150 150 -PUT 151 151 -PUT 152 152 -PUT 153 153 -PUT 154 154 -PUT 155 155 -PUT 156 156 -PUT 157 157 -PUT 158 158 -PUT 159 159 -PUT 160 160 -PUT 161 161 -PUT 162 162 -PUT 163 163 -PUT 164 164 -PUT 165 165 -PUT 166 166 -PUT 167 167 -PUT 168 168 -PUT 169 169 -PUT 170 170 -PUT 171 171 -PUT 172 172 -PUT 173 173 -PUT 174 174 -PUT 175 175 -PUT 176 176 -PUT 177 177 -PUT 178 178 -PUT 179 179 -PUT 180 180 -PUT 181 181 -PUT 182 182 -PUT 183 183 -PUT 184 184 -PUT 185 185 -PUT 186 186 -PUT 187 187 -PUT 188 188 -PUT 189 189 -PUT 190 190 -PUT 191 191 -PUT 192 192 -PUT 193 193 -PUT 194 194 -PUT 195 195 -PUT 196 196 -PUT 197 197 -PUT 198 198 -PUT 199 199 -PUT 200 200 -PUT 201 201 -PUT 202 202 -PUT 203 203 -PUT 204 204 -PUT 205 205 -PUT 206 206 -PUT 207 207 -PUT 208 208 -PUT 209 209 -PUT 210 210 -PUT 211 211 -PUT 212 212 -PUT 213 213 -PUT 214 214 -PUT 215 215 -PUT 216 216 -PUT 217 217 -PUT 218 218 -PUT 219 219 -PUT 220 220 -PUT 221 221 -PUT 222 222 -PUT 223 223 -PUT 224 224 -PUT 225 225 -PUT 226 226 -PUT 227 227 -PUT 228 228 -PUT 229 229 -PUT 230 230 -PUT 231 231 -PUT 232 232 -PUT 233 233 -PUT 234 234 -PUT 235 235 -PUT 236 236 -PUT 237 237 -PUT 238 238 -PUT 239 239 -PUT 240 240 -PUT 241 241 -PUT 242 242 -PUT 243 243 -PUT 244 244 -PUT 245 245 -PUT 246 246 -PUT 247 247 -PUT 248 248 -PUT 249 249 -PUT 250 250 -PUT 251 251 -PUT 252 252 -PUT 253 253 -PUT 254 254 -PUT 255 255 -PUT 256 256 -GET 129 -GET 130 -GET 131 -GET 132 -GET 133 -GET 134 -GET 135 -GET 136 -GET 137 -GET 138 -GET 139 -GET 140 -GET 141 -GET 142 -GET 143 -GET 144 -GET 145 -GET 146 -GET 147 -GET 148 -GET 149 -GET 150 -GET 151 -GET 152 -GET 153 -GET 154 -GET 155 -GET 156 -GET 157 -GET 158 -GET 159 -GET 160 -GET 161 -GET 162 -GET 163 -GET 164 -GET 165 -GET 166 -GET 167 -GET 168 -GET 169 -GET 170 -GET 171 -GET 172 -GET 173 -GET 174 -GET 175 -GET 176 -GET 177 -GET 178 -GET 179 -GET 180 -GET 181 -GET 182 -GET 183 -GET 184 -GET 185 -GET 186 -GET 187 -GET 188 -GET 189 -GET 190 -GET 191 -GET 192 -GET 193 -GET 194 -GET 195 -GET 196 -GET 197 -GET 198 -GET 199 -GET 200 -GET 201 -GET 202 -GET 203 -GET 204 -GET 205 -GET 206 -GET 207 -GET 208 -GET 209 -GET 210 -GET 211 -GET 212 -GET 213 -GET 214 -GET 215 -GET 216 -GET 217 -GET 218 -GET 219 -GET 220 -GET 221 -GET 222 -GET 223 -GET 224 -GET 225 -GET 226 -GET 227 -GET 228 -GET 229 -GET 230 -GET 231 -GET 232 -GET 233 -GET 234 -GET 235 -GET 236 -GET 237 -GET 238 -GET 239 -GET 240 -GET 241 -GET 242 -GET 243 -GET 244 -GET 245 -GET 246 -GET 247 -GET 248 -GET 249 -GET 250 -GET 251 -GET 252 -GET 253 -GET 254 -GET 255 -GET 256 -PUT 257 257 -PUT 258 258 -PUT 259 259 -PUT 260 260 -PUT 261 261 -PUT 262 262 -PUT 263 263 -PUT 264 264 -PUT 265 265 -PUT 266 266 -PUT 267 267 -PUT 268 268 -PUT 269 269 -PUT 270 270 -PUT 271 271 -PUT 272 272 -PUT 273 273 -PUT 274 274 -PUT 275 275 -PUT 276 276 -PUT 277 277 -PUT 278 278 -PUT 279 279 -PUT 280 280 -PUT 281 281 -PUT 282 282 -PUT 283 283 -PUT 284 284 -PUT 285 285 -PUT 286 286 -PUT 287 287 -PUT 288 288 -PUT 289 289 -PUT 290 290 -PUT 291 291 -PUT 292 292 -PUT 293 293 -PUT 294 294 -PUT 295 295 -PUT 296 296 -PUT 297 297 -PUT 298 298 -PUT 299 299 -PUT 300 300 -PUT 301 301 -PUT 302 302 -PUT 303 303 -PUT 304 304 -PUT 305 305 -PUT 306 306 -PUT 307 307 -PUT 308 308 -PUT 309 309 -PUT 310 310 -PUT 311 311 -PUT 312 312 -PUT 313 313 -PUT 314 314 -PUT 315 315 -PUT 316 316 -PUT 317 317 -PUT 318 318 -PUT 319 319 -PUT 320 320 -PUT 321 321 -PUT 322 322 -PUT 323 323 -PUT 324 324 -PUT 325 325 -PUT 326 326 -PUT 327 327 -PUT 328 328 -PUT 329 329 -PUT 330 330 -PUT 331 331 -PUT 332 332 -PUT 333 333 -PUT 334 334 -PUT 335 335 -PUT 336 336 -PUT 337 337 -PUT 338 338 -PUT 339 339 -PUT 340 340 -PUT 341 341 -PUT 342 342 -PUT 343 343 -PUT 344 344 -PUT 345 345 -PUT 346 346 -PUT 347 347 -PUT 348 348 -PUT 349 349 -PUT 350 350 -PUT 351 351 -PUT 352 352 -PUT 353 353 -PUT 354 354 -PUT 355 355 -PUT 356 356 -PUT 357 357 -PUT 358 358 -PUT 359 359 -PUT 360 360 -PUT 361 361 -PUT 362 362 -PUT 363 363 -PUT 364 364 -PUT 365 365 -PUT 366 366 -PUT 367 367 -PUT 368 368 -PUT 369 369 -PUT 370 370 -PUT 371 371 -PUT 372 372 -PUT 373 373 -PUT 374 374 -PUT 375 375 -PUT 376 376 -PUT 377 377 -PUT 378 378 -PUT 379 379 -PUT 380 380 -PUT 381 381 -PUT 382 382 -PUT 383 383 -PUT 384 384 -GET 257 -GET 258 -GET 259 -GET 260 -GET 261 -GET 262 -GET 263 -GET 264 -GET 265 -GET 266 -GET 267 -GET 268 -GET 269 -GET 270 -GET 271 -GET 272 -GET 273 -GET 274 -GET 275 -GET 276 -GET 277 -GET 278 -GET 279 -GET 280 -GET 281 -GET 282 -GET 283 -GET 284 -GET 285 -GET 286 -GET 287 -GET 288 -GET 289 -GET 290 -GET 291 -GET 292 -GET 293 -GET 294 -GET 295 -GET 296 -GET 297 -GET 298 -GET 299 -GET 300 -GET 301 -GET 302 -GET 303 -GET 304 -GET 305 -GET 306 -GET 307 -GET 308 -GET 309 -GET 310 -GET 311 -GET 312 -GET 313 -GET 314 -GET 315 -GET 316 -GET 317 -GET 318 -GET 319 -GET 320 -GET 321 -GET 322 -GET 323 -GET 324 -GET 325 -GET 326 -GET 327 -GET 328 -GET 329 -GET 330 -GET 331 -GET 332 -GET 333 -GET 334 -GET 335 -GET 336 -GET 337 -GET 338 -GET 339 -GET 340 -GET 341 -GET 342 -GET 343 -GET 344 -GET 345 -GET 346 -GET 347 -GET 348 -GET 349 -GET 350 -GET 351 -GET 352 -GET 353 -GET 354 -GET 355 -GET 356 -GET 357 -GET 358 -GET 359 -GET 360 -GET 361 -GET 362 -GET 363 -GET 364 -GET 365 -GET 366 -GET 367 -GET 368 -GET 369 -GET 370 -GET 371 -GET 372 -GET 373 -GET 374 -GET 375 -GET 376 -GET 377 -GET 378 -GET 379 -GET 380 -GET 381 -GET 382 -GET 383 -GET 384 -PUT 385 385 -PUT 386 386 -PUT 387 387 -PUT 388 388 -PUT 389 389 -PUT 390 390 -PUT 391 391 -PUT 392 392 -PUT 393 393 -PUT 394 394 -PUT 395 395 -PUT 396 396 -PUT 397 397 -PUT 398 398 -PUT 399 399 -PUT 400 400 -PUT 401 401 -PUT 402 402 -PUT 403 403 -PUT 404 404 -PUT 405 405 -PUT 406 406 -PUT 407 407 -PUT 408 408 -PUT 409 409 -PUT 410 410 -PUT 411 411 -PUT 412 412 -PUT 413 413 -PUT 414 414 -PUT 415 415 -PUT 416 416 -PUT 417 417 -PUT 418 418 -PUT 419 419 -PUT 420 420 -PUT 421 421 -PUT 422 422 -PUT 423 423 -PUT 424 424 -PUT 425 425 -PUT 426 426 -PUT 427 427 -PUT 428 428 -PUT 429 429 -PUT 430 430 -PUT 431 431 -PUT 432 432 -PUT 433 433 -PUT 434 434 -PUT 435 435 -PUT 436 436 -PUT 437 437 -PUT 438 438 -PUT 439 439 -PUT 440 440 -PUT 441 441 -PUT 442 442 -PUT 443 443 -PUT 444 444 -PUT 445 445 -PUT 446 446 -PUT 447 447 -PUT 448 448 -PUT 449 449 -PUT 450 450 -PUT 451 451 -PUT 452 452 -PUT 453 453 -PUT 454 454 -PUT 455 455 -PUT 456 456 -PUT 457 457 -PUT 458 458 -PUT 459 459 -PUT 460 460 -PUT 461 461 -PUT 462 462 -PUT 463 463 -PUT 464 464 -PUT 465 465 -PUT 466 466 -PUT 467 467 -PUT 468 468 -PUT 469 469 -PUT 470 470 -PUT 471 471 -PUT 472 472 -PUT 473 473 -PUT 474 474 -PUT 475 475 -PUT 476 476 -PUT 477 477 -PUT 478 478 -PUT 479 479 -PUT 480 480 -PUT 481 481 -PUT 482 482 -PUT 483 483 -PUT 484 484 -PUT 485 485 -PUT 486 486 -PUT 487 487 -PUT 488 488 -PUT 489 489 -PUT 490 490 -PUT 491 491 -PUT 492 492 -PUT 493 493 -PUT 494 494 -PUT 495 495 -PUT 496 496 -PUT 497 497 -PUT 498 498 -PUT 499 499 -PUT 500 500 -PUT 501 501 -PUT 502 502 -PUT 503 503 -PUT 504 504 -PUT 505 505 -PUT 506 506 -PUT 507 507 -PUT 508 508 -PUT 509 509 -PUT 510 510 -PUT 511 511 -PUT 512 512 -GET 385 -GET 386 -GET 387 -GET 388 -GET 389 -GET 390 -GET 391 -GET 392 -GET 393 -GET 394 -GET 395 -GET 396 -GET 397 -GET 398 -GET 399 -GET 400 -GET 401 -GET 402 -GET 403 -GET 404 -GET 405 -GET 406 -GET 407 -GET 408 -GET 409 -GET 410 -GET 411 -GET 412 -GET 413 -GET 414 -GET 415 -GET 416 -GET 417 -GET 418 -GET 419 -GET 420 -GET 421 -GET 422 -GET 423 -GET 424 -GET 425 -GET 426 -GET 427 -GET 428 -GET 429 -GET 430 -GET 431 -GET 432 -GET 433 -GET 434 -GET 435 -GET 436 -GET 437 -GET 438 -GET 439 -GET 440 -GET 441 -GET 442 -GET 443 -GET 444 -GET 445 -GET 446 -GET 447 -GET 448 -GET 449 -GET 450 -GET 451 -GET 452 -GET 453 -GET 454 -GET 455 -GET 456 -GET 457 -GET 458 -GET 459 -GET 460 -GET 461 -GET 462 -GET 463 -GET 464 -GET 465 -GET 466 -GET 467 -GET 468 -GET 469 -GET 470 -GET 471 -GET 472 -GET 473 -GET 474 -GET 475 -GET 476 -GET 477 -GET 478 -GET 479 -GET 480 -GET 481 -GET 482 -GET 483 -GET 484 -GET 485 -GET 486 -GET 487 -GET 488 -GET 489 -GET 490 -GET 491 -GET 492 -GET 493 -GET 494 -GET 495 -GET 496 -GET 497 -GET 498 -GET 499 -GET 500 -GET 501 -GET 502 -GET 503 -GET 504 -GET 505 -GET 506 -GET 507 -GET 508 -GET 509 -GET 510 -GET 511 -GET 512 -PUT 513 513 -FREE diff --git a/tests/cache/lfu/cache-new.expect b/tests/cache/lfu/cache-new.expect deleted file mode 100644 index 134d8b8e..00000000 --- a/tests/cache/lfu/cache-new.expect +++ /dev/null @@ -1,2 +0,0 @@ -NEW CACHE -FREE CACHE diff --git a/tests/cache/lfu/cache-put.expect b/tests/cache/lfu/cache-put.expect deleted file mode 100644 index eae31924..00000000 --- a/tests/cache/lfu/cache-put.expect +++ /dev/null @@ -1,3 +0,0 @@ -NEW CACHE -REPLACE 1 -FREE CACHE diff --git a/tests/cache/lfu/cache-put.in b/tests/cache/lfu/cache-put.in deleted file mode 100644 index f20edfa3..00000000 --- a/tests/cache/lfu/cache-put.in +++ /dev/null @@ -1,259 +0,0 @@ -NEW -PUT 1 1 -PUT 2 2 -PUT 3 3 -PUT 4 4 -PUT 5 5 -PUT 6 6 -PUT 7 7 -PUT 8 8 -PUT 9 9 -PUT 10 10 -PUT 11 11 -PUT 12 12 -PUT 13 13 -PUT 14 14 -PUT 15 15 -PUT 16 16 -PUT 17 17 -PUT 18 18 -PUT 19 19 -PUT 20 20 -PUT 21 21 -PUT 22 22 -PUT 23 23 -PUT 24 24 -PUT 25 25 -PUT 26 26 -PUT 27 27 -PUT 28 28 -PUT 29 29 -PUT 30 30 -PUT 31 31 -PUT 32 32 -PUT 33 33 -PUT 34 34 -PUT 35 35 -PUT 36 36 -PUT 37 37 -PUT 38 38 -PUT 39 39 -PUT 40 40 -PUT 41 41 -PUT 42 42 -PUT 43 43 -PUT 44 44 -PUT 45 45 -PUT 46 46 -PUT 47 47 -PUT 48 48 -PUT 49 49 -PUT 50 50 -PUT 51 51 -PUT 52 52 -PUT 53 53 -PUT 54 54 -PUT 55 55 -PUT 56 56 -PUT 57 57 -PUT 58 58 -PUT 59 59 -PUT 60 60 -PUT 61 61 -PUT 62 62 -PUT 63 63 -PUT 64 64 -PUT 65 65 -PUT 66 66 -PUT 67 67 -PUT 68 68 -PUT 69 69 -PUT 70 70 -PUT 71 71 -PUT 72 72 -PUT 73 73 -PUT 74 74 -PUT 75 75 -PUT 76 76 -PUT 77 77 -PUT 78 78 -PUT 79 79 -PUT 80 80 -PUT 81 81 -PUT 82 82 -PUT 83 83 -PUT 84 84 -PUT 85 85 -PUT 86 86 -PUT 87 87 -PUT 88 88 -PUT 89 89 -PUT 90 90 -PUT 91 91 -PUT 92 92 -PUT 93 93 -PUT 94 94 -PUT 95 95 -PUT 96 96 -PUT 97 97 -PUT 98 98 -PUT 99 99 -PUT 100 100 -PUT 101 101 -PUT 102 102 -PUT 103 103 -PUT 104 104 -PUT 105 105 -PUT 106 106 -PUT 107 107 -PUT 108 108 -PUT 109 109 -PUT 110 110 -PUT 111 111 -PUT 112 112 -PUT 113 113 -PUT 114 114 -PUT 115 115 -PUT 116 116 -PUT 117 117 -PUT 118 118 -PUT 119 119 -PUT 120 120 -PUT 121 121 -PUT 122 122 -PUT 123 123 -PUT 124 124 -PUT 125 125 -PUT 126 126 -PUT 127 127 -PUT 128 128 -PUT 129 129 -PUT 130 130 -PUT 131 131 -PUT 132 132 -PUT 133 133 -PUT 134 134 -PUT 135 135 -PUT 136 136 -PUT 137 137 -PUT 138 138 -PUT 139 139 -PUT 140 140 -PUT 141 141 -PUT 142 142 -PUT 143 143 -PUT 144 144 -PUT 145 145 -PUT 146 146 -PUT 147 147 -PUT 148 148 -PUT 149 149 -PUT 150 150 -PUT 151 151 -PUT 152 152 -PUT 153 153 -PUT 154 154 -PUT 155 155 -PUT 156 156 -PUT 157 157 -PUT 158 158 -PUT 159 159 -PUT 160 160 -PUT 161 161 -PUT 162 162 -PUT 163 163 -PUT 164 164 -PUT 165 165 -PUT 166 166 -PUT 167 167 -PUT 168 168 -PUT 169 169 -PUT 170 170 -PUT 171 171 -PUT 172 172 -PUT 173 173 -PUT 174 174 -PUT 175 175 -PUT 176 176 -PUT 177 177 -PUT 178 178 -PUT 179 179 -PUT 180 180 -PUT 181 181 -PUT 182 182 -PUT 183 183 -PUT 184 184 -PUT 185 185 -PUT 186 186 -PUT 187 187 -PUT 188 188 -PUT 189 189 -PUT 190 190 -PUT 191 191 -PUT 192 192 -PUT 193 193 -PUT 194 194 -PUT 195 195 -PUT 196 196 -PUT 197 197 -PUT 198 198 -PUT 199 199 -PUT 200 200 -PUT 201 201 -PUT 202 202 -PUT 203 203 -PUT 204 204 -PUT 205 205 -PUT 206 206 -PUT 207 207 -PUT 208 208 -PUT 209 209 -PUT 210 210 -PUT 211 211 -PUT 212 212 -PUT 213 213 -PUT 214 214 -PUT 215 215 -PUT 216 216 -PUT 217 217 -PUT 218 218 -PUT 219 219 -PUT 220 220 -PUT 221 221 -PUT 222 222 -PUT 223 223 -PUT 224 224 -PUT 225 225 -PUT 226 226 -PUT 227 227 -PUT 228 228 -PUT 229 229 -PUT 230 230 -PUT 231 231 -PUT 232 232 -PUT 233 233 -PUT 234 234 -PUT 235 235 -PUT 236 236 -PUT 237 237 -PUT 238 238 -PUT 239 239 -PUT 240 240 -PUT 241 241 -PUT 242 242 -PUT 243 243 -PUT 244 244 -PUT 245 245 -PUT 246 246 -PUT 247 247 -PUT 248 248 -PUT 249 249 -PUT 250 250 -PUT 251 251 -PUT 252 252 -PUT 253 253 -PUT 254 254 -PUT 255 255 -PUT 256 256 -PUT 257 257 -FREE diff --git a/tests/cache/test-cache.c b/tests/cache/test-cache.c index 8a0b7d97..b81b9b76 100644 --- a/tests/cache/test-cache.c +++ b/tests/cache/test-cache.c @@ -5,12 +5,12 @@ #include "cache.h" -static void print_value(int *val) +static void print_value(int *val, int freq) { if (val) - printf("%d\n", *val); + printf("%d %d\n", *val, freq); else - printf("NULL\n"); + printf("NULL %d\n", freq); } static void split(char **arr, char *str, const char *del) @@ -23,8 +23,12 @@ static void split(char **arr, char *str, const char *del) } } -/* Commands of test-cache - * 1. NEW: cache_create(8), the cache size is set to 256. +#define N_CACHE_BITS 4 + +/* + * Commands of test-cache: + * 1. NEW: cache_create(N_CACHE_BITS), the cache size is set to pow(2, + * N_CACHE_BITS). * 2. GET key: cache_get(cache, key, true) * 3. PUT key val: cache_put(cache, key, val) * 4. FREE: cache_free(cache, free) @@ -37,28 +41,29 @@ int main(int argc, char *argv[]) FILE *fp = fopen(argv[1], "r"); assert(fp); - char *line = NULL, *ptr = NULL; + char *line = NULL; size_t len = 0; struct cache *cache = NULL; - int key, *ans, *val; + int key, freq, *ans, *val; while (getline(&line, &len, fp) != -1) { char *arr[3]; split(arr, line, " "); if (!strcmp(arr[0], "GET")) { - key = (int) strtol(arr[1], &ptr, 10); + key = (int) strtol(arr[1], NULL, 10); ans = cache_get(cache, key, true); - print_value(ans); + freq = cache_freq(cache, key); + print_value(ans, freq); } else if (!strcmp(arr[0], "PUT")) { - key = (int) strtol(arr[1], &ptr, 10); + key = (int) strtol(arr[1], NULL, 10); val = malloc(sizeof(int)); - *val = (int) strtol(arr[2], &ptr, 10); + *val = (int) strtol(arr[2], NULL, 10); val = cache_put(cache, key, val); if (val) { printf("REPLACE %d\n", *val); free(val); } } else if (!strcmp(arr[0], "NEW\n")) { - cache = cache_create(8); + cache = cache_create(N_CACHE_BITS); assert(cache); printf("NEW CACHE\n"); } else if (!strcmp(arr[0], "FREE\n")) { @@ -67,6 +72,7 @@ int main(int argc, char *argv[]) } } fclose(fp); + free(line); return 0; } From 8e7ab814503d33d01238269e35d7ec6e05b3d4fa Mon Sep 17 00:00:00 2001 From: Vacantron Chen Date: Sat, 30 Nov 2024 22:56:21 +0800 Subject: [PATCH 2/4] Prevent data race between T1C and T2C T2C uses the translated blocks (IRs) to establish the LLVM-IR. However, the cache might be modified by the main thread while the background thread is compiling. --- src/emulate.c | 13 ++++++++++++- src/riscv.c | 4 ++++ src/riscv_private.h | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/emulate.c b/src/emulate.c index 4dca078d..5c54c1bb 100644 --- a/src/emulate.c +++ b/src/emulate.c @@ -832,11 +832,19 @@ static block_t *block_find_or_translate(riscv_t *rv) #else list_add(&next_blk->list, &rv->block_list); +#if RV32_HAS(T2C) + pthread_mutex_lock(&rv->cache_lock); +#endif + /* insert the block into block cache */ block_t *replaced_blk = cache_put(rv->block_cache, rv->PC, next_blk); - if (!replaced_blk) + if (!replaced_blk) { +#if RV32_HAS(T2C) + pthread_mutex_unlock(&rv->cache_lock); +#endif return next_blk; + } list_del_init(&replaced_blk->list); @@ -872,6 +880,9 @@ static block_t *block_find_or_translate(riscv_t *rv) } mpool_free(rv->block_mp, replaced_blk); +#if RV32_HAS(T2C) + pthread_mutex_unlock(&rv->cache_lock); +#endif #endif assert(next_blk); diff --git a/src/riscv.c b/src/riscv.c index 74756846..df84bac1 100644 --- a/src/riscv.c +++ b/src/riscv.c @@ -201,7 +201,9 @@ static void *t2c_runloop(void *arg) pthread_mutex_lock(&rv->wait_queue_lock); list_del_init(&entry->list); pthread_mutex_unlock(&rv->wait_queue_lock); + pthread_mutex_lock(&rv->cache_lock); t2c_compile(rv, entry->block); + pthread_mutex_unlock(&rv->cache_lock); free(entry); } } @@ -324,6 +326,7 @@ riscv_t *rv_create(riscv_user_t rv_attr) rv->jit_cache = jit_cache_init(); /* prepare wait queue. */ pthread_mutex_init(&rv->wait_queue_lock, NULL); + pthread_mutex_init(&rv->cache_lock, NULL); INIT_LIST_HEAD(&rv->wait_queue); /* activate the background compilation thread. */ pthread_create(&t2c_thread, NULL, t2c_runloop, rv); @@ -422,6 +425,7 @@ void rv_delete(riscv_t *rv) rv->quit = true; pthread_join(t2c_thread, NULL); pthread_mutex_destroy(&rv->wait_queue_lock); + pthread_mutex_destroy(&rv->cache_lock); jit_cache_exit(rv->jit_cache); #endif jit_state_exit(rv->jit_state); diff --git a/src/riscv_private.h b/src/riscv_private.h index 43e0bb53..a0388844 100644 --- a/src/riscv_private.h +++ b/src/riscv_private.h @@ -175,7 +175,7 @@ struct riscv_internal { struct list_head block_list; /**< list of all translated blocks */ #if RV32_HAS(T2C) struct list_head wait_queue; - pthread_mutex_t wait_queue_lock; + pthread_mutex_t wait_queue_lock, cache_lock; volatile bool quit; /**< Determine the main thread is terminated or not */ #endif #endif From 73dc2dd12c14125f751575f342a4c04fe82ef1cd Mon Sep 17 00:00:00 2001 From: Vacantron Chen Date: Sat, 30 Nov 2024 22:53:47 +0800 Subject: [PATCH 3/4] Bump LLVM and update Makefile --- Makefile | 62 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 71f4b9e2..7feca7e3 100644 --- a/Makefile +++ b/Makefile @@ -141,35 +141,39 @@ endif ENABLE_JIT ?= 0 $(call set-feature, JIT) ifeq ($(call has, JIT), 1) -OBJS_EXT += jit.o -# tier-2 JIT compiler powered LLVM -LLVM_CONFIG = llvm-config-17 -LLVM_CONFIG := $(shell which $(LLVM_CONFIG)) -ifndef LLVM_CONFIG -# Try Homebrew on macOS -LLVM_CONFIG = /opt/homebrew/opt/llvm@17/bin/llvm-config -LLVM_CONFIG := $(shell which $(LLVM_CONFIG)) -ifdef LLVM_CONFIG -LDFLAGS += -L/opt/homebrew/opt/llvm@17/lib -endif -endif -ifneq ("$(LLVM_CONFIG)", "") -ifneq ("$(findstring -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS, "$(shell $(LLVM_CONFIG) --cflags)")", "") -ENABLE_T2C := 1 -$(call set-feature, T2C) -OBJS_EXT += t2c.o -CFLAGS += -g $(shell $(LLVM_CONFIG) --cflags) -LDFLAGS += $(shell $(LLVM_CONFIG) --libs) -else -ENABLE_T2C := 0 -$(call set-feature, T2C) -$(warning No llvm-config-17 installed. Check llvm-config-17 installation in advance) -endif -endif - -ifneq ($(processor),$(filter $(processor),x86_64 aarch64 arm64)) -$(error JIT mode only supports for x64 and arm64 target currently.) -endif + OBJS_EXT += jit.o + ENABLE_T2C ?= 1 + $(call set-feature, T2C) + ifeq ($(call has, T2C), 1) + # tier-2 JIT compiler is powered by LLVM + LLVM_CONFIG = llvm-config-18 + LLVM_CONFIG := $(shell which $(LLVM_CONFIG)) + ifndef LLVM_CONFIG + # Try Homebrew on macOS + LLVM_CONFIG = /opt/homebrew/opt/llvm@18/bin/llvm-config + LLVM_CONFIG := $(shell which $(LLVM_CONFIG)) + ifdef LLVM_CONFIG + LDFLAGS += -L/opt/homebrew/opt/llvm@18/lib + endif + endif + ifeq ("$(LLVM_CONFIG)", "") + $(error No llvm-config-18 installed. Check llvm-config-18 installation in advance, or use "ENABLE_T2C=0" to disable tier-2 LLVM compiler) + endif + ifeq ("$(findstring -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS, "$(shell $(LLVM_CONFIG) --cflags)")", "") + $(error No llvm-config-18 installed. Check llvm-config-18 installation in advance, or use "ENABLE_T2C=0" to disable tier-2 LLVM compiler) + endif + CHECK_LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs 2>/dev/null 1>&2; echo $$?) + ifeq ("$(CHECK_LLVM_LIBS)", "0") + OBJS_EXT += t2c.o + CFLAGS += -g $(shell $(LLVM_CONFIG) --cflags) + LDFLAGS += $(shell $(LLVM_CONFIG) --libs) + else + $(error No llvm-config-18 installed. Check llvm-config-18 installation in advance, or use "ENABLE_T2C=0" to disable tier-2 LLVM compiler) + endif + endif + ifneq ($(processor),$(filter $(processor),x86_64 aarch64 arm64)) + $(error JIT mode only supports for x64 and arm64 target currently.) + endif src/rv32_jit.c: $(Q)tools/gen-jit-template.py $(CFLAGS) > $@ From 5ffb157eeaecdfd165f26949914fd8e7a326e217 Mon Sep 17 00:00:00 2001 From: Vacantron Chen Date: Mon, 2 Dec 2024 19:22:25 +0800 Subject: [PATCH 4/4] Suppress warnings from "scan-build" --- src/cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cache.c b/src/cache.c index 4a07fe91..90da4221 100644 --- a/src/cache.c +++ b/src/cache.c @@ -76,6 +76,7 @@ static inline int hlist_empty(const struct hlist_head *h) static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) { +#ifndef __clang_analyzer__ struct hlist_node *first = h->first; n->next = first; if (first) @@ -83,6 +84,7 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) h->first = n; n->pprev = &h->first; +#endif } static inline bool hlist_unhashed(const struct hlist_node *h)