Skip to content

Commit 9646c8e

Browse files
authored
[CLEANUP]: Remove deprecated type (1a1a11a#276)
* [CLEANUP] Remove deprecated type * Remove obj id type in fast23 * Fix error message
1 parent e205c13 commit 9646c8e

8 files changed

Lines changed: 68 additions & 94 deletions

File tree

doc/API.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ typedef struct reader {
2323
size_t file_size;
2424

2525
trace_type_e trace_type; /* possible types see trace_type_t */
26-
obj_id_type_e obj_id_type; /* possible types see obj_id_type_e in request.h */
2726

2827
size_t item_size; /* the size of one record, used to
2928
* locate the memory location of next element,
@@ -53,21 +52,18 @@ typedef struct reader {
5352
* @param trace_path
5453
* @param trace_type CSV_TRACE, PLAIN_TXT_TRACE, BIN_TRACE, VSCSI_TRACE,
5554
* TWR_BIN_TRACE
56-
* @param obj_id_type OBJ_ID_NUM, OBJ_ID_STR
5755
* @param setup_params
5856
* @return a pointer to reader_t struct, the returned reader needs to be
5957
* explicitly closed by calling close_reader or close_trace
6058
*/
6159
reader_t *setup_reader(const char *trace_path, const trace_type_e trace_type,
62-
const obj_id_type_e obj_id_type,
6360
const reader_init_param_t *const reader_init_param);
6461

6562
/* this is the same function as setup_reader */
6663
static inline reader_t *
6764
open_trace(const char *path, const trace_type_e type,
68-
const obj_id_type_e obj_id_type,
6965
const reader_init_param_t *const reader_init_param) {
70-
return setup_reader(path, type, obj_id_type, reader_init_param);
66+
return setup_reader(path, type, reader_init_param);
7167
}
7268

7369
/**
@@ -86,15 +82,6 @@ static inline trace_type_e get_trace_type(const reader_t *const reader) {
8682
return reader->trace_type;
8783
}
8884

89-
/**
90-
* as the name suggests
91-
* @param reader
92-
* @return
93-
*/
94-
static inline obj_id_type_e get_obj_id_type(const reader_t *const reader) {
95-
return reader->obj_id_type;
96-
}
97-
9885
/**
9986
* read one request from reader/trace, stored the info in pre-allocated req
10087
* @param reader
@@ -159,7 +146,3 @@ simulate_at_multi_sizes_with_step_size(reader_t *const reader_in,
159146
160147
161148
profiler:
162-
163-
164-
165-

doc/advanced_lib.md

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# libCacheSim library user guide
2-
libCacheSim is a library to build fast cache simulators.
1+
# libCacheSim library user guide
2+
libCacheSim is a library to build fast cache simulators.
33
With its high-throughput, low-footprint, flexible API design, libCacheSim can simulate large caches within seconds to minutes.
4-
Some example usages of libCacheSim
5-
* design/compare cache admission/eviction algorithms.
4+
Some example usages of libCacheSim
5+
* design/compare cache admission/eviction algorithms.
66
* design/compare trace sampling techniques.
7-
* simulate a complex cache hierarchy and topology.
8-
For example, build a cache hierarchy with multiple layers to study the impact of exclusive and inclusive caching; or build a cache cluster with consistent hashing to explore the different load balancing techniques on caching.
7+
* simulate a complex cache hierarchy and topology.
8+
For example, build a cache hierarchy with multiple layers to study the impact of exclusive and inclusive caching; or build a cache cluster with consistent hashing to explore the different load balancing techniques on caching.
99

1010

1111
---
1212

13-
## libCacheSim Modules
14-
Currently there are four main modules in libCacheSim,
13+
## libCacheSim Modules
14+
Currently there are four main modules in libCacheSim,
1515
* **bin**: a set of binary tools including cachesim, traceConv, etc.
16-
* **traceReader**: a module providing trace parsing and reading, currently supports csv, txt, and binary traces.
17-
* **cache**: it includes three modules --- eviction, admission and prefetching.
18-
* **eviction**: provides a set of cache eviction algorithms such as LRU, LFU, FIFO, CLOCK, ARC, LFUDA (LFU with dynamic aging), SLRU, Hyperbolic, LHD, LeCaR, Cacheus, GLCache, etc.
16+
* **traceReader**: a module providing trace parsing and reading, currently supports csv, txt, and binary traces.
17+
* **cache**: it includes three modules --- eviction, admission and prefetching.
18+
* **eviction**: provides a set of cache eviction algorithms such as LRU, LFU, FIFO, CLOCK, ARC, LFUDA (LFU with dynamic aging), SLRU, Hyperbolic, LHD, LeCaR, Cacheus, GLCache, etc.
1919
* **admission**: provides a set of admission algorithms including size, bloomFilter, adaptSize.
20-
* **prefetch**: provides various prefetch algorithms, currently it is not used.
20+
* **prefetch**: provides various prefetch algorithms, currently it is not used.
2121

2222
---
2323

@@ -37,9 +37,9 @@ bool LRU_remove(cache_t *cache, const obj_id_t obj_id);
3737
```
3838
3939
#### Create Cache
40-
We can create a cache by calling the cache initialization function, such as for LRU
40+
We can create a cache by calling the cache initialization function, such as for LRU
4141
```c
42-
cache_t *cache = LRU_init(common_cache_params, NULL);
42+
cache_t *cache = LRU_init(common_cache_params, NULL);
4343
```
4444
The common_cache_params is a `common_cache_params_t` struct, the hashpower is the estimated size of hash table, default is 24, which means default hash table size is `1 << 24` (16777216) objects. Note that setting an appropriate
4545
```c
@@ -49,7 +49,7 @@ typedef struct {
4949
int hashpower;
5050
} common_cache_params_t;
5151
```
52-
Note that setting an appropriate hashpower can reduce the number of times hash table expands, but only set it if you know what you doing, otherwise, leave it as the default.
52+
Note that setting an appropriate hashpower can reduce the number of times hash table expands, but only set it if you know what you doing, otherwise, leave it as the default.
5353

5454
#### Close/free the cache
5555
```c
@@ -58,7 +58,7 @@ cache->cache_free(cache);
5858
```
5959
6060
#### Cache get
61-
This is the highest level cache API, which tries to find the object in the cache. If found, it updates the cache state (e.g., moving the object to the head of queue in LRU); otherwise, it inserts the object in the cache, and evict if necessary.
61+
This is the highest level cache API, which tries to find the object in the cache. If found, it updates the cache state (e.g., moving the object to the head of queue in LRU); otherwise, it inserts the object in the cache, and evict if necessary.
6262
```c
6363
// req is the request, see the next section for reading from a trace
6464
cache->get(cache, req);
@@ -67,30 +67,30 @@ cache->get(cache, req);
6767
The APIs below is lower level API, if you use the lower level API, you need to explicitly update the `n_req` field of the cache after each user request, otherwise, some algorithms that rely on virtual time may not work correctly.
6868

6969
#### Cache find
70-
This is the lower level cache API, which tries to find the object in the cache. If found, it updates the cache state if `update_cache` is true, and return the found object; otherwise, it returns NULL.
70+
This is the lower level cache API, which tries to find the object in the cache. If found, it updates the cache state if `update_cache` is true, and return the found object; otherwise, it returns NULL.
7171
```c
7272
cache->find(cache, req, update_cache);
7373
```
7474
7575
#### Cache insert
76-
This is the lower level cache API, which tries to insert the object in the cache. If the object can be inserted into the cache, it returns the inserted object. Otherwise, it returns NULL.
76+
This is the lower level cache API, which tries to insert the object in the cache. If the object can be inserted into the cache, it returns the inserted object. Otherwise, it returns NULL.
7777
78-
Note that there are cases that the object is not inserted into the cache, e.g., the object is too large to fit in the cache.
78+
Note that there are cases that the object is not inserted into the cache, e.g., the object is too large to fit in the cache.
7979
80-
Because this is the second level API, this function does not perform eviction and assumes the cache has enough space.
81-
If using this function, you need to explicitly call `evict` to evict objects.
80+
Because this is the second level API, this function does not perform eviction and assumes the cache has enough space.
81+
If using this function, you need to explicitly call `evict` to evict objects.
8282
```c
8383
cache->insert(cache, req);
8484
```
8585

8686
#### Cache evict
87-
This is the lower level cache API, which tries to evict the object in the cache. If the object can be evicted from the cache, it returns the evicted object. Otherwise, it returns NULL.
87+
This is the lower level cache API, which tries to evict the object in the cache. If the object can be evicted from the cache, it returns the evicted object. Otherwise, it returns NULL.
8888
```c
8989
cache->evict(cache, req);
9090
```
9191
9292
#### Cache remove
93-
This is the lower level cache API, which tries to remove the object in the cache. If the object is in the cache and can be removed, it returns true. Otherwise, it returns false.
93+
This is the lower level cache API, which tries to remove the object in the cache. If the object is in the cache and can be removed, it returns true. Otherwise, it returns false.
9494
Note that this function should not be used for eviction purpose.
9595
```c
9696
cache->remove(cache, obj_id);
@@ -105,75 +105,73 @@ cache->to_evict(cache, req);
105105
106106
### TraceReader APIs
107107
There are mostly three APIs related to readers, `open_trace`, `close_trace`, `read_one_req`, let's take a look how
108-
they work.
108+
they work.
109109
110110
##### Setup a txt reader (trace can only contain request id)
111111
```c
112-
open_trace(data_path, PLAIN_TXT_TRACE, obj_id_type, NULL);
112+
open_trace(data_path, PLAIN_TXT_TRACE, NULL);
113113
```
114-
obj_id_type can be `OBJ_ID_NUM` or `OBJ_ID_STR`, if the object id is a number then use `OBJ_ID_NUM`, otherwise use
115-
`OBJ_ID_STR`.
116-
117-
##### Setup a csv reader
114+
115+
##### Setup a csv reader
118116
```c
119-
reader_init_param_t init_params_csv =
120-
{.delimiter=',', .time_field=2, .obj_id_field=6, .obj_size_field=4, .has_header=FALSE};
121-
reader_t *reader_csv_c = open_trace("data/trace.csv", CSV_TRACE, OBJ_ID_STR, &init_params_csv);
117+
reader_init_param_t init_params_csv =
118+
{.delimiter=',', .time_field=2, .obj_id_field=6, .obj_size_field=4, .has_header=FALSE};
119+
reader_t *reader_csv_c = open_trace("data/trace.csv", CSV_TRACE, &init_params_csv);
122120
```
123121
124-
##### Setup a binary reader
122+
##### Setup a binary reader
125123
```c
126124
reader_init_param_t init_params_bin = {.binary_fmt="<3I2H2Q", .obj_size_field=2, .obj_id_field=6, };
127-
reader_t *reader_bin_l = setup_reader("data/trace.vscsi", BIN_TRACE, OBJ_ID_NUM, &init_params_bin);
125+
reader_t *reader_bin_l = setup_reader("data/trace.vscsi", BIN_TRACE, &init_params_bin);
128126
```
129-
The format of a binary trace is the same as
130-
[Python struct format specifier](https://docs.python.org/3/library/struct.html).
131-
127+
The format of a binary trace is the same as
128+
[Python struct format specifier](https://docs.python.org/3/library/struct.html).
129+
132130

133131

134132

135-
### Simulator APIs
136-
The simulator API allows you to run multiple simulations at the same time.
133+
### Simulator APIs
134+
The simulator API allows you to run multiple simulations at the same time.
137135
The different simulations can have different cache sizes or different cache eviction algorithms.
138136

139137
```c
140138
// simulate multiple cache sizes specified using cache_sizes
141-
// warmup_reader and warmup_perc is optional, if you do not need to warmup your cache, just pass `NULL` and 0.
139+
// warmup_reader and warmup_perc is optional, if you do not need to warmup your cache, just pass `NULL` and 0.
142140
sim_res_t *
143-
simulate_at_multi_sizes(reader_t reader*,
144-
cache_t *cache,
145-
int num_of_sizes,
141+
simulate_at_multi_sizes(reader_t reader*,
142+
cache_t *cache,
143+
int num_of_sizes,
146144
uint64_t *cache_sizes,
147-
reader_t *warmup_reader,
148-
double warmup_perc,
145+
reader_t *warmup_reader,
146+
double warmup_perc,
149147
int num_of_threads);
150148

151149
// simulate multiple cache sizes from step_size to cache->cache_size
152150
// it runs cache->cache_size/step_size simulations
153151
sim_res_t *
154-
simulate_at_multi_sizes_with_step_size(reader_t *reader,
155-
cache_t *cache,
156-
uint64_t step_size,
157-
reader_t *warmup_reader,
158-
double warmup_perc,
152+
simulate_at_multi_sizes_with_step_size(reader_t *reader,
153+
cache_t *cache,
154+
uint64_t step_size,
155+
reader_t *warmup_reader,
156+
double warmup_perc,
159157
int num_of_threads);
160158

161159
// simulate with multiple caches, which can have different eviction algorithms or sizes
162-
cache_stat_t *simulate_with_multi_caches(reader_t *reader,
160+
cache_stat_t *simulate_with_multi_caches(reader_t *reader,
163161
cache_t *caches[],
164162
int num_of_caches,
165163
reader_t *warmup_reader,
166-
double warmup_frac,
164+
double warmup_frac,
167165
int warmup_sec,
168166
int num_of_threads)
169167
```
170168
171-
`simulate_at_multi_sizes` allows you to pass in an array of `cache_sizes` to simulate;
169+
`simulate_at_multi_sizes` allows you to pass in an array of `cache_sizes` to simulate;
172170
`simulate_at_multi_sizes_with_step_size` allows you to specify the step size to simulate, the simulations will run at
173-
cache sizes `step_size, step_size*2, step_size*3 .. cache->cache_size`.
171+
cache sizes `step_size, step_size*2, step_size*3 .. cache->cache_size`.
174172
`simulate_with_multi_caches` allows you to pass in an array of `cache_t` to simulate, which can have different eviction algorithms or sizes.
175173
176-
The return result is an array of simulation results, the users are responsible for free the array.
174+
The return result is an array of simulation results, the users are responsible for free the array.
177175
```c
178176
typedef struct {
179177
uint64_t req_cnt;
@@ -187,27 +185,27 @@ typedef struct {
187185
```
188186

189187

190-
### Trace utils
191-
#### get reuse/stack distance
188+
### Trace utils
189+
#### get reuse/stack distance
192190
```c
193191
// get the stack distance (number of uniq objects) since last access or till next request
194192
// reader: trace reader
195193
// dist_type: STACK_DIST or FUTURE_STACK_DIST
196194
// return an array of int32_t with size written in array_size
197-
int32_t *get_stack_dist(reader_t *reader,
195+
int32_t *get_stack_dist(reader_t *reader,
198196
const dist_type_e dist_type,
199197
int64_t *array_size);
200198

201199
// get the distance (number of requests) since last/first access
202200
// reader: trace reader
203201
// dist_type DIST_SINCE_LAST_ACCESS or DIST_SINCE_FIRST_ACCESS
204202
// return an array of int32_t with size written in array_size
205-
int32_t *get_access_dist(reader_t *reader,
203+
int32_t *get_access_dist(reader_t *reader,
206204
const dist_type_e dist_type,
207205
int64_t *array_size);
208206
```
209207
210-
## Examples
208+
## Examples
211209
#### C example
212210
213211
@@ -220,10 +218,10 @@ int32_t *get_access_dist(reader_t *reader,
220218
### Build a cache cluster with consistent hashing
221219
222220
223-
## FAQ
221+
## FAQ
224222
#### Linking with libCacheSim
225-
linking can be done in cmake or use pkg-config
226-
Such as in the `_build` directory:
223+
linking can be done in cmake or use pkg-config
224+
Such as in the `_build` directory:
227225
```
228226
export PKG_CONFIG_PATH=$PWD
229227
```
@@ -234,7 +232,3 @@ export PKG_CONFIG_PATH=$PWD
234232
235233
236234
---
237-
238-
239-
240-

libCacheSim/bin/customized/fast23/compareGrouping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void compareGrouping::cal_group_metric_utility(string trace_path,
323323
vector<int> &group_sizes,
324324
int n_repeat, int n_thread) {
325325
reader_t *reader =
326-
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, OBJ_ID_NUM, nullptr);
326+
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, nullptr);
327327
request_t *req = new_request();
328328
int64_t n_total_req = get_num_of_req(reader);
329329
int64_t n_skip = n_total_req / 10;

libCacheSim/bin/customized/fast23/compareGroups.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void compareGroups::cal_group_metric_utility_over_time(string trace_path,
5656
string ofilepath,
5757
int group_size) {
5858
reader_t *reader =
59-
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, OBJ_ID_NUM, nullptr);
59+
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, nullptr);
6060
request_t *req = new_request();
6161
int64_t n_skip = 0;
6262
int64_t n_req = n_skip;

libCacheSim/bin/customized/fast23/objectInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct map_val {
3838
std::vector<fast23::obj_reuse_stat> objectInfo::compute_obj_reuse_stat(
3939
std::string trace_path) {
4040
reader_t *reader =
41-
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, OBJ_ID_NUM, nullptr);
41+
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, nullptr);
4242
request_t *req = new_request();
4343
int64_t n_req = 0;
4444
unordered_map<uint64_t, shared_ptr<struct map_val>> objmap;
@@ -93,7 +93,7 @@ int64_t objectInfo::convert_trace_to_requests(
9393
std::string trace_path, fast23::request_info *request_info,
9494
int64_t request_info_size, int64_t n_skip) {
9595
reader_t *reader =
96-
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, OBJ_ID_NUM, nullptr);
96+
open_trace(trace_path.c_str(), ORACLE_GENERAL_BIN, nullptr);
9797
request_t *req = new_request();
9898
int64_t n_req = n_skip;
9999

libCacheSim/include/libCacheSim/plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extern "C" {
4444
*
4545
* @param cache_alg_name Name of the cache replacement algorithm (case
4646
* sensitive)
47-
* @param cc_params General cache parameters (cache_size, obj_id_type,
47+
* @param cc_params General cache parameters (cache_size,
4848
* support_ttl, etc.)
4949
* @param cache_specific_params Algorithm-specific parameters (can be NULL)
5050
* @return Pointer to initialized cache handler, or NULL on failure

libCacheSim/include/libCacheSim/reader.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ static inline reader_init_param_t default_reader_init_params(void) {
182182
* @param trace_path path to the trace
183183
* @param trace_type CSV_TRACE, PLAIN_TXT_TRACE, BIN_TRACE, VSCSI_TRACE,
184184
* TWR_BIN_TRACE, see libCacheSim/enum.h for more
185-
* @param obj_id_type OBJ_ID_NUM, OBJ_ID_STR,
186-
* used by CSV_TRACE and PLAIN_TXT_TRACE, whether the obj_id in the trace is a
187-
* number or not, if it is not a number then we will map it to uint64_t
188185
* @param reader_init_param some initialization parameters used by csv and
189186
* binary traces these include time_field, obj_id_field, obj_size_field,
190187
* op_field, ttl_field, has_header, delimiter, binary_fmt_str

libCacheSim/traceReader/reader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ int read_one_req(reader_t *const reader, request_t *const req) {
301301
break;
302302
default:
303303
ERROR(
304-
"cannot recognize reader obj_id_type, given reader obj_id_type: "
304+
"cannot recognize reader trace_type, given reader trace_type: "
305305
"%c\n",
306306
reader->trace_type);
307307
abort();

0 commit comments

Comments
 (0)