Skip to content

Commit

Permalink
*: disambiguate scan length option
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdroychan committed Aug 6, 2024
1 parent 2fbedc1 commit 9f2eb48
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion presets/benchmarks/example_scan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ threads = 8
repeat = 5
qd = 100
batch = 10
scan = 10
scan_n = 10
klen = 8
vlen = 16
kmin = 0
Expand Down
16 changes: 8 additions & 8 deletions src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ pub struct GlobalOpt {
pub latency: Option<bool>,
pub cdf: Option<bool>,
// workload
pub scan: Option<usize>,
pub scan_n: Option<usize>,
pub klen: Option<usize>,
pub vlen: Option<usize>,
pub kmin: Option<usize>,
Expand All @@ -379,7 +379,7 @@ impl Default for GlobalOpt {
report: None,
latency: None,
cdf: None,
scan: None,
scan_n: None,
klen: None,
vlen: None,
kmin: None,
Expand Down Expand Up @@ -408,11 +408,11 @@ impl GlobalOpt {
.clone()
.or_else(|| Some(self.cdf.clone().unwrap_or(false)));
// the workload options (fall back to defaults)
opt.workload.scan = opt
opt.workload.scan_n = opt
.workload
.scan
.scan_n
.clone()
.or_else(|| Some(self.scan.clone().unwrap_or(10)));
.or_else(|| Some(self.scan_n.clone().unwrap_or(10)));
// the workload options (must be specified)
opt.workload.klen = opt
.workload
Expand Down Expand Up @@ -1112,7 +1112,7 @@ mod tests {
report = "finish"
latency = true
cdf = true
scan = 500
scan_n = 500
klen = 8
vlen = 16
kmin = 100
Expand All @@ -1136,7 +1136,7 @@ mod tests {
del_perc: 10,
scan_perc: 10,
dist: "incrementp".to_string(),
scan: Some(500),
scan_n: Some(500),
klen: Some(8),
vlen: Some(16),
kmin: Some(100),
Expand Down Expand Up @@ -1186,8 +1186,8 @@ mod tests {
get_perc: 30,
del_perc: 10,
scan_perc: 10,
scan_n: Some(10),
dist: "shufflep".to_string(),
scan: Some(10),
klen: Some(8),
vlen: Some(16),
kmin: Some(1),
Expand Down
41 changes: 22 additions & 19 deletions src/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub struct WorkloadOpt {
pub scan_perc: u8,

/// The number of iterations per `SCAN` (only used when `scan_perc` is non-zero, default 10).
pub scan: Option<usize>,
pub scan_n: Option<usize>,

/// Key length in bytes.
pub klen: Option<usize>,
Expand Down Expand Up @@ -219,7 +219,7 @@ pub struct Workload {
/// Key generator based on distribution
kgen: KeyGenerator,
/// Scan length
scan: usize,
scan_n: usize,
/// Value length for operations that need a value
vlen: usize,
/// How many operations have been access so far
Expand All @@ -234,12 +234,12 @@ impl Workload {
100,
"sum of ops in a mix should be 100"
);
let scan = opt.scan.expect("scan should be specified");
let scan_n = opt.scan_n.expect("scan_n should be specified");
let klen = opt.klen.expect("klen should be specified");
let vlen = opt.vlen.expect("vlen should be specified");
let kmin = opt.kmin.expect("kmin should be specified");
let kmax = opt.kmax.expect("kmax should be specified");
assert!(scan > 0, "scan size should be positive");
assert!(scan_n > 0, "scan size should be positive");
assert!(klen > 0, "klen should be positive");
assert!(kmax > kmin, "kmax should be greater than kmin");

Expand Down Expand Up @@ -286,7 +286,7 @@ impl Workload {
Self {
mix,
kgen,
scan,
scan_n,
vlen,
count: 0,
}
Expand Down Expand Up @@ -316,7 +316,10 @@ impl Workload {
}
OperationType::Get => Operation::Get { key },
OperationType::Delete => Operation::Delete { key },
OperationType::Scan => Operation::Scan { key, n: self.scan },
OperationType::Scan => Operation::Scan {
key,
n: self.scan_n,
},
}
}

Expand Down Expand Up @@ -516,7 +519,7 @@ mod tests {
get_perc = 20
del_perc = 5
scan_perc = 5
scan = 10
scan_n = 10
klen = 4
vlen = 6
dist = "uniform"
Expand All @@ -533,7 +536,7 @@ mod tests {
get_perc = 20
del_perc = 5
scan_perc = 5
scan = 10
scan_n = 10
klen = 40
vlen = 60
dist = "zipfian"
Expand All @@ -552,7 +555,7 @@ mod tests {
get_perc = 25
del_perc = 10
scan_perc = 5
scan = 10
scan_n = 10
klen = 14
vlen = 16
dist = "shuffle"
Expand All @@ -573,7 +576,7 @@ mod tests {
get_perc = 40
del_perc = 0
scan_perc = 0
scan = 10
scan_n = 10
klen = 0
vlen = 6
dist = "uniform"
Expand All @@ -589,7 +592,7 @@ mod tests {
get_perc = 40
del_perc = 0
scan_perc = 0
scan = 0
scan_n = 0
klen = 2
vlen = 6
dist = "uniform"
Expand All @@ -605,7 +608,7 @@ mod tests {
get_perc = 40
del_perc = 0
scan_perc = 0
scan = 10
scan_n = 10
dist = "uniform"
kmin = 0
kmax = 12345"#;
Expand All @@ -619,7 +622,7 @@ mod tests {
get_perc = 40
del_perc = 0
scan_perc = 0
scan = 10
scan_n = 10
klen = 4
vlen = 6
dist = "uniform"
Expand All @@ -635,7 +638,7 @@ mod tests {
get_perc = 40
del_perc = 0
scan_perc = 0
scan = 10
scan_n = 10
klen = 4
vlen = 6
dist = "uniform"
Expand All @@ -651,7 +654,7 @@ mod tests {
get_perc = 30
del_perc = 0
scan_perc = 0
scan = 10
scan_n = 10
klen = 4
vlen = 6
dist = "uniorm"
Expand All @@ -667,7 +670,7 @@ mod tests {
get_perc: 50,
del_perc: 0,
scan_perc: 0,
scan: Some(10),
scan_n: Some(10),
klen: Some(16),
vlen: Some(100),
dist: "incrementp".to_string(),
Expand Down Expand Up @@ -703,7 +706,7 @@ mod tests {
get_perc: 0,
del_perc: 0,
scan_perc: 0,
scan: Some(10),
scan_n: Some(10),
klen: Some(16),
vlen: Some(100),
dist: "incrementp".to_string(),
Expand Down Expand Up @@ -742,7 +745,7 @@ mod tests {
get_perc: 95,
del_perc: 0,
scan_perc: 0,
scan: Some(10),
scan_n: Some(10),
klen: Some(16),
vlen: Some(100),
dist: "latest".to_string(),
Expand Down Expand Up @@ -789,7 +792,7 @@ mod tests {
get_perc: 50,
del_perc: 0,
scan_perc: 0,
scan: Some(10),
scan_n: Some(10),
klen: Some(16),
vlen: Some(100),
dist: "uniform".to_string(),
Expand Down

0 comments on commit 9f2eb48

Please sign in to comment.