-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrand_write_bench.py
executable file
·143 lines (127 loc) · 3.76 KB
/
rand_write_bench.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env python3
import os
from bench_utils import *
import argparse
JOB_RAMP = "10s"
JOB_RUN = "120m"
FILL_BS = "128k"
FILL_QD = 1
FILL_RAND_BS = "4k"
FILL_RAND_QD = 1
STEADY_BS = "4k"
STEADY_QD = 1
RAND_BS = "4k"
RAND_QD = 1
def main(
fio: str,
model: str,
device: str,
lbaf: str,
overwrite: bool,
mock: bool,
):
# Setup tools
job_gen = FioJobGenerator(overwrite)
fio = FioRunner(fio, overwrite)
nvme = NVMeRunnerCLI(device) if not mock else NVMeRunnerMock(device)
# Investigate device
zns = nvme.is_zoned()
numa_node = nvme.get_numa_node()
min_size = nvme.get_min_request_size()
if zns:
print("Rand not supported on ZNS")
return
# Clean state
nvme.clean_device()
# Prefill
fill_path = BenchPath(
IOEngine.IO_URING, model, lbaf, "prefill", 1, FILL_QD, FILL_BS
).AbsPathOut()
fio.run_job(
f"{PREDEFINED_JOB_PATH}/precodition_fill.fio",
fill_path,
[f"FILENAME=/dev/{device}", f"BW_PATH={fill_path}", f"LOG_PATH={fill_path}"],
mock=mock,
)
# Prefill rand
fill_rand_path = BenchPath(
IOEngine.IO_URING, model, lbaf, "rand_fill", 1, FILL_RAND_QD, FILL_RAND_BS
).AbsPathOut()
fio.run_job(
f"{PREDEFINED_JOB_PATH}/precodition_rand_nvme.fio",
fill_rand_path,
[
f"FILENAME=/dev/{device}",
f"BW_PATH={fill_rand_path}",
f"LOG_PATH={fill_rand_path}",
f"BS={FILL_RAND_BS}",
],
mock=mock,
)
# steady_state path
steady_path = BenchPath(
IOEngine.IO_URING, model, lbaf, "steady", 1, STEADY_QD, STEADY_BS
).AbsPathOut()
fio.run_job(
f"{PREDEFINED_JOB_PATH}/steady_state_nvme.fio",
steady_path,
[
f"FILENAME=/dev/{device}",
f"BW_PATH={steady_path}",
f"LOG_PATH={steady_path}",
f"BS={STEADY_BS}",
f"STEADY=1%",
],
mock=mock,
)
job_defaults = [
DirectOption(True),
GroupReportingOption(True),
ThreadOption(True),
TimedOption(JOB_RAMP, JOB_RUN),
NumaPinOption(numa_node),
IOEngineOption(IOEngine.IO_URING),
DefaultIOUringOption(),
TargetOption(f"/dev/{device}"),
JobOption(JobWorkload.RAN_WRITE),
RequestSizeOption(RAND_BS),
QDOption(RAND_QD),
]
job = FioGlobalJob()
sjob = FioSubJob(f"qd{RAND_QD}")
# paths
path = BenchPath(IOEngine.IO_URING, model, lbaf, "randwrite", 1, RAND_BS, RAND_QD)
sjob.add_options(job_defaults)
# Do not leak paths in job file, use env var
sjob.add_option2("write_bw_log", "${BW_PATH}")
sjob.add_option2("write_lat_log", "${LOG_PATH}")
sjob.add_option2("log_avg_msec", "10ms")
job.add_job(sjob)
# Write job file
job_gen.generate_job_file(path.AbsPathJob(), job)
# run job
fio.run_job(
path.AbsPathJob(),
path.AbsPathOut(),
[f"BW_PATH={path.AbsPathOut()}", f"LOG_PATH={path.AbsPathOut()}"],
mock=mock,
)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Do investigative tests on an NVMe drive in grid fashion"
)
parser.add_argument("-d", "--device", type=str, required=True)
parser.add_argument("-m", "--model", type=str, required=True)
parser.add_argument("-f", "--fio", type=str, required=True)
parser.add_argument("-l", "--lbaf", type=str, required=True)
parser.add_argument("--mock", type=bool, required=False, default=False)
parser.add_argument("-o", "--overwrite", type=str, required=False, default=False)
args = parser.parse_args()
main(
args.fio,
args.model,
args.device,
args.lbaf,
args.overwrite,
args.mock,
)