traceReader:
typedefstruct {
inttime_field;
intobj_id_field;
intobj_size_field;
intop_field;
intttl_field;
// csv readergbooleanhas_header;
chardelimiter;
// binary readercharbinary_fmt[MAX_BIN_FMT_STR_LEN];
} reader_init_param_t;
typedefstructreader {
char*mapped_file; /* mmap the file, this should not change during runtime */uint64_tmmap_offset;
FILE*file;
size_tfile_size;
trace_type_etrace_type; /* possible types see trace_type_t */obj_id_type_eobj_id_type; /* possible types see obj_id_type_e in request.h */size_titem_size; /* the size of one record, used to * locate the memory location of next element, * when used in vscsiReaser and binaryReader, * it is a const value, * when it is used in plainReader or csvReader, * it is the size of last record, it does not * include LFCR or \0 */uint64_tn_total_req; /* number of requests in the trace */uint64_tn_uniq_obj; /* number of objects in the trace */chartrace_path[MAX_FILE_PATH_LEN];
reader_init_param_tinit_params;
void*reader_params;
void*other_params; /* currently not used */gintver;
boolcloned; // true if this is a cloned reader, else false
} reader_t;
/** * setup the reader struct for reading trace * @param trace_path * @param trace_type CSV_TRACE, PLAIN_TXT_TRACE, BIN_TRACE, VSCSI_TRACE, * TWR_BIN_TRACE * @param obj_id_type OBJ_ID_NUM, OBJ_ID_STR * @param setup_params * @return a pointer to reader_t struct, the returned reader needs to be * explicitly closed by calling close_reader or close_trace */reader_t*setup_reader(constchar*trace_path, consttrace_type_etrace_type,
constobj_id_type_eobj_id_type,
constreader_init_param_t*constreader_init_param);
/* this is the same function as setup_reader */staticinlinereader_t*open_trace(constchar*path, consttrace_type_etype,
constobj_id_type_eobj_id_type,
constreader_init_param_t*constreader_init_param) {
returnsetup_reader(path, type, obj_id_type, reader_init_param);
}
/** * read one request from reader, and store it in the pre-allocated request_t req * @param reader * @param req */uint64_tget_num_of_req(reader_t*constreader);
/** * as the name suggests * @param reader * @return */staticinlinetrace_type_eget_trace_type(constreader_t*constreader) {
returnreader->trace_type;
}
/** * as the name suggests * @param reader * @return */staticinlineobj_id_type_eget_obj_id_type(constreader_t*constreader) {
returnreader->obj_id_type;
}
/** * read one request from reader/trace, stored the info in pre-allocated req * @param reader * @param req * return 0 on success and 1 if reach end of trace */intread_one_req(reader_t*constreader, request_t*constreq);
/** * reset reader, so we can read from the beginning * @param reader */voidreset_reader(reader_t*constreader);
/** * close reader and release resources * @param reader * @return */intclose_reader(reader_t*constreader);
/** * clone a reader, mostly used in multithreading * @param reader * @return */reader_t*clone_reader(constreader_t*constreader);cache and cacheAlgo:
staticinlinerequest_t*new_request();
staticinlinevoidcopy_request(request_t*req_dest, request_t*req_src);
staticinlinerequest_t*clone_request(request_t*req);
staticinlinevoidfree_request(request_t*req);
staticinlinevoidprint_request(request_t*req);simulator:
sim_res_t*simulate_at_multi_sizes(reader_t*constreader,
constcache_t*constcache,
constgintnum_of_sizes,
constguint64*constcache_sizes,
reader_t*constwarmup_reader,
constdoublewarmup_perc,
constgintnum_of_threads);
sim_res_t*simulate_at_multi_sizes_with_step_size(reader_t*constreader_in,
constcache_t*constcache_in,
constguint64step_size,
reader_t*constwarmup_reader,
constdoublewarmup_perc,
constgintnum_of_threads);profiler: