| 32 | |
| 33 | |
| 34 | void run_cache(reader_t *reader, cache_t *cache) { |
| 35 | request_t *req = new_request(); |
| 36 | uint64_t req_cnt = 0, miss_cnt = 0; |
| 37 | uint64_t last_req_cnt = 0, last_miss_cnt = 0; |
| 38 | |
| 39 | read_one_req(reader, req); |
| 40 | uint64_t start_ts = (uint64_t)req->clock_time; |
| 41 | uint64_t last_report_ts = req->clock_time - start_ts; |
| 42 | |
| 43 | double start_time = gettime(); |
| 44 | while (req->valid) { |
| 45 | req->clock_time -= start_ts; |
| 46 | |
| 47 | #ifdef FIFO_REDUCE_METADATA |
| 48 | req->obj_size -= 12; |
| 49 | #endif // FIFO_REDUCE_METADATA |
| 50 | #ifdef ADD_METADATA |
| 51 | req->obj_size += 32; |
| 52 | #endif // ADD_METADATA |
| 53 | |
| 54 | #ifdef NO_FRAGMENTATION |
| 55 | #ifdef NO_CALCIFICATION |
| 56 | #ifndef ADD_METADATA |
| 57 | #error "ERROR: NO_CALCIFICATION requires ADD_METADATA\n" |
| 58 | #endif // ADD_METADATA |
| 59 | // value + key + metadata NO_CALCIFICATION |
| 60 | req->obj_size = size_mapping[160 + 24 + 32]; |
| 61 | #else // NO NO_CALCIFICATION |
| 62 | // object size = value + key |
| 63 | req->obj_size = size_mapping[req->obj_size]; |
| 64 | #endif // NO_CALCIFICATION |
| 65 | #endif // NO_FRAGMENTATION |
| 66 | |
| 67 | #ifdef SAMPLING_RATIO |
| 68 | if (req->obj_id % (SAMPLING_RATIO * 100 + 1) > 100) { |
| 69 | read_one_req(reader, req); |
| 70 | continue; |
| 71 | } |
| 72 | #endif // SAMPLING_RATIO |
| 73 | |
| 74 | if (req->op == OP_SET || req->op == OP_REPLACE) { |
| 75 | cache->get(cache, req); |
| 76 | } else if (req->op == OP_DELETE) { |
| 77 | cache->remove(cache, req->obj_id); |
| 78 | } else { |
| 79 | req_cnt++; |
| 80 | if (cache->get(cache, req) == false) { |
| 81 | miss_cnt++; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if (req->clock_time - last_report_ts >= 3600 * 24 && req->clock_time != 0) { |
| 86 | INFO( |
| 87 | "%.2lf hour: %lu requests, miss ratio %.4lf, interval miss ratio " |
| 88 | "%.4lf\n", |
| 89 | (double)req->clock_time / 3600, (unsigned long)req_cnt, |
| 90 | (double)miss_cnt / req_cnt, |
| 91 | (double)(miss_cnt - last_miss_cnt) / (req_cnt - last_req_cnt)); |
no test coverage detected