Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/quickstart_cachesim.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ You can use `-p` or `--prefetch` to set the prefetching algorithm.
# use part of the trace to warm up the cache
./bin/cachesim ../data/cloudPhysicsIO.vscsi vscsi lru 1gb --warmup-sec=86400

# Use TTL
./bin/cachesim ../data/cloudPhysicsIO.vscsi vscsi lru 1gb --use-ttl=true
# TTL: a build with -DSUPPORT_TTL=ON uses the TTL in the trace by default;
# --use-ttl=false replays the trace as if it carried no TTL. A build without
# SUPPORT_TTL ignores TTLs and rejects --use-ttl=true
./bin/cachesim ../data/cloudPhysicsIO.vscsi vscsi lru 1gb --use-ttl=false

# Disable the print of the first few requests
./bin/cachesim ../data/cloudPhysicsIO.vscsi vscsi lru 1gb --print-head-req=false
Expand Down
20 changes: 17 additions & 3 deletions libCacheSim/bin/MRC/parser_mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ static struct argp_option options[] = {
{"report-interval", OPTION_REPORT_INTERVAL, "3600", 0,
"how often to report stat when running one cache", 10},
{"warmup-sec", OPTION_WARMUP_SEC, "0", 0, "warm up time in seconds", 10},
{"use-ttl", OPTION_USE_TTL, "false", 0, "specify to use ttl from the trace",
{"use-ttl", OPTION_USE_TTL, "true|false", 0,
"use the TTL in the trace (default: true in builds with SUPPORT_TTL, "
"which true requires)",
10},
{"consider-obj-metadata", OPTION_CONSIDER_OBJ_METADATA, "false", 0,
"Whether consider per object metadata size in the simulated cache", 10},
Expand Down Expand Up @@ -145,6 +147,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break;
case OPTION_USE_TTL:
arguments->use_ttl = is_true(arg) ? true : false;
#ifndef SUPPORT_TTL
if (arguments->use_ttl)
argp_error(state,
"error: --use-ttl true needs a build with -DSUPPORT_TTL=ON");
#endif
break;
case OPTION_REPORT_INTERVAL:
arguments->report_interval = atol(arg);
Expand Down Expand Up @@ -218,7 +225,11 @@ static void init_mini_arg(struct MINI_arguments *args) {
args->trace_type_str = NULL;
args->trace_type_params = NULL;
args->verbose = true;
#ifdef SUPPORT_TTL
args->use_ttl = true;
#else
args->use_ttl = false;
#endif
args->ignore_obj_size = false;
args->consider_obj_metadata = false;
args->report_interval = 3600 * 24;
Expand Down Expand Up @@ -303,6 +314,7 @@ void parse_mini_cmd(int argc, char *argv[], struct MINI_arguments *args) {
reader_init_params.obj_id_is_num = true;
reader_init_params.cap_at_n_req = args->n_req;
reader_init_params.sampler = NULL;
reader_init_params.ignore_ttl = !args->use_ttl;

parse_reader_params(args->trace_type_params, &reader_init_params);

Expand Down Expand Up @@ -542,8 +554,10 @@ void print_parsed_args(struct MINI_arguments *args) {
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1,
", eviction-params: %s", args->eviction_params);

if (args->use_ttl)
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1, ", use ttl");
#ifdef SUPPORT_TTL
if (!args->use_ttl)
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1, ", ignore ttl");
#endif

if (args->ignore_obj_size)
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1,
Expand Down
20 changes: 17 additions & 3 deletions libCacheSim/bin/cachesim/cli_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ static struct argp_option options[] = {
{"report-interval", OPTION_REPORT_INTERVAL, "3600", 0,
"how often to report stat when running one cache", 10},
{"warmup-sec", OPTION_WARMUP_SEC, "0", 0, "warm up time in seconds", 10},
{"use-ttl", OPTION_USE_TTL, "false", 0, "specify to use ttl from the trace",
{"use-ttl", OPTION_USE_TTL, "true|false", 0,
"use the TTL in the trace (default: true in builds with SUPPORT_TTL, "
"which true requires)",
10},
{"consider-obj-metadata", OPTION_CONSIDER_OBJ_METADATA, "false", 0,
"Whether consider per object metadata size in the simulated cache", 10},
Expand Down Expand Up @@ -176,6 +178,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break;
case OPTION_USE_TTL:
arguments->use_ttl = is_true(arg) ? true : false;
#ifndef SUPPORT_TTL
if (arguments->use_ttl)
argp_error(state,
"error: --use-ttl true needs a build with -DSUPPORT_TTL=ON");
#endif
break;
case OPTION_REPORT_INTERVAL:
arguments->report_interval =
Expand Down Expand Up @@ -274,7 +281,11 @@ static void init_arg(struct arguments *args) {
args->trace_type_str = NULL;
args->trace_type_params = NULL;
args->verbose = true;
#ifdef SUPPORT_TTL
args->use_ttl = true;
#else
args->use_ttl = false;
#endif
args->ignore_obj_size = false;
args->consider_obj_metadata = false;
args->hashpower = DEFAULT_HASHPOWER;
Expand Down Expand Up @@ -367,6 +378,7 @@ void parse_cmd(int argc, char *argv[], struct arguments *args) {
reader_init_params.obj_id_is_num = true;
reader_init_params.cap_at_n_req = args->n_req;
reader_init_params.sampler = NULL;
reader_init_params.ignore_ttl = !args->use_ttl;

parse_reader_params(args->trace_type_params, &reader_init_params);

Expand Down Expand Up @@ -632,8 +644,10 @@ void print_parsed_args(struct arguments *args) {
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1, ", hashpower %d",
args->hashpower);

if (args->use_ttl)
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1, ", use ttl");
#ifdef SUPPORT_TTL
if (!args->use_ttl)
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1, ", ignore ttl");
#endif

if (args->ignore_obj_size)
n += snprintf(output_str + n, OUTPUT_STR_LEN - n - 1,
Expand Down
4 changes: 4 additions & 0 deletions libCacheSim/include/libCacheSim/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ typedef struct {
/* Reject oracle filtering that invalidates future-access metadata.
* Offline-policy callers should enable this before reading or cloning. */
bool require_valid_next_access;

// if true, drop the TTL of every request (req->ttl = 0), so a build with
// SUPPORT_TTL replays the trace as if it carried no TTL
bool ignore_ttl;
} reader_init_param_t;

enum read_direction {
Expand Down
4 changes: 4 additions & 0 deletions libCacheSim/traceReader/readerRequest.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ int read_one_req(reader_t *const reader, request_t *const req) {
req->obj_size = 1;
}

if (reader->init_params.ignore_ttl) {
req->ttl = 0;
}

/* lcp derives cost from block position rather than from a column */
if (reader->init_params.obj_cost_field <= 0 &&
reader->trace_type != LCP_TRACE) {
Expand Down
23 changes: 23 additions & 0 deletions test/test_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,29 @@ expect_output "cachesim hashes string object ids" "miss ratio 0\.6667" \
"${BIN_DIR}/cachesim" str-ids.csv csv lru 1mb \
-t "time-col=1,obj-id-col=2,obj-size-col=3,has-header=true"

# --use-ttl. Object 1 has a TTL of 5 and is read again at t=10. Without TTLs
# that read hits (two misses in three requests); with TTLs it misses.
cat >ttl.csv <<'CSV'
time,id,size,ttl
1,1,100,5
2,2,100,0
10,1,100,0
CSV
TTL_FMT="time-col=1,obj-id-col=2,obj-size-col=3,ttl-col=4,has-header=true"
# A build without SUPPORT_TTL rejects --use-ttl=true; probe it on a trace
# without TTLs, since an expired read crashes TTL builds until #349 is fixed.
if "${BIN_DIR}/cachesim" str-ids.csv csv lru 1mb --use-ttl=true \
-t "time-col=1,obj-id-col=2,obj-size-col=3,has-header=true" 2>&1 |
grep -q "SUPPORT_TTL"; then
expect_clean_error "cachesim --use-ttl=true without SUPPORT_TTL" \
"${BIN_DIR}/cachesim" ttl.csv csv lru 1mb -t "${TTL_FMT}" --use-ttl=true
expect_output "cachesim ignores TTLs without SUPPORT_TTL" "miss ratio 0\.6667" \
"${BIN_DIR}/cachesim" ttl.csv csv lru 1mb -t "${TTL_FMT}"
else
expect_output "cachesim --use-ttl=false drops the trace TTL" "miss ratio 0\.6667" \
"${BIN_DIR}/cachesim" ttl.csv csv lru 1mb -t "${TTL_FMT}" --use-ttl=false
fi

echo "running synthetic reader tests"
for spec in Uniform_1000_10 Zipf_1000_10_0 Zipf_1000_10_1 \
Zipf_1000_10_1.2_42 Zipf_1000_10_.5 Zipf_1000_10_1e-310; do
Expand Down
Loading