blob: a2b0b0043b5da5433efc9b64c1e0aff38167495a [file] [log] [blame]
koder aka kdanilov8ad6e812015-03-22 14:42:18 +02001import sys
2import argparse
koder aka kdanilov6e2ae792015-03-04 18:02:24 -08003
koder aka kdanilovf86d7af2015-05-06 04:01:54 +03004from disk_perf_test_tool.utils import ssize2b
koder aka kdanilov6e2ae792015-03-04 18:02:24 -08005
6
7def make_list(x):
8 if not isinstance(x, (list, tuple)):
9 return [x]
10 return x
11
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080012
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020013def make_load(settings):
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080014
15 iodepth = 1
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020016 for conc in make_list(settings.concurrences):
17 for bsize in make_list(settings.sizes):
18 for oper in make_list(settings.opers):
19 for cache_mode in make_list(settings.cache_modes):
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080020
21 # filter out too slow options
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020022 if bsize in "1k 4k" and cache_mode == "a":
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080023 continue
24
25 # filter out sync reads
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020026 if oper in "read randread" and cache_mode == "s":
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080027 continue
28
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020029 if settings.io_size is not None:
30 size_sync_opts = " --iosize " + str(settings.io_size)
31 if cache_mode == "s":
32 size_sync_opts += " -s"
33 elif cache_mode == "d":
34 size_sync_opts += " -d"
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080035 else:
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020036 if cache_mode == "s":
37 size_sync_opts = "--iosize {0} -s".format(
38 settings.sync_default_size)
39 elif cache_mode == "d":
40 if oper == 'randread':
41 assert settings.sync_default_size[0] == 'x'
42 max_f = int(settings.sync_default_size[1:])
43 else:
44 max_f = None
45
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030046 mmax_f = ssize2b(settings.hdd_size) / \
47 (int(conc) * ssize2b(bsize))
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020048
49 if max_f is None or mmax_f > max_f:
50 max_f = mmax_f
51
52 assert settings.direct_default_size[0] == 'x'
53 if max_f > int(settings.direct_default_size[1:]):
54 max_f = settings.direct_default_size
55 else:
56 max_f = "x{0}".format(max_f)
57
58 size_sync_opts = "--iosize {0} -d".format(max_f)
59
koder aka kdanilovce5444f2015-03-14 09:19:02 +020060 else:
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020061 if oper == 'randread' or oper == 'read':
62 size_sync_opts = "--iosize " + \
63 str(settings.sync_default_size)
64 else:
65 size_sync_opts = "--iosize " + \
66 str(settings.sync_default_size)
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080067
68 # size_sync_opts = get_file_size_opts(sync_type)
69
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020070 io_opts = "--type {0} ".format(settings.tester_type)
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080071 io_opts += "-a {0} ".format(oper)
72 io_opts += "--iodepth {0} ".format(iodepth)
73 io_opts += "--blocksize {0} ".format(bsize)
74 io_opts += size_sync_opts + " "
75 io_opts += "--concurrency {0}".format(conc)
76
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020077 for i in range(settings.repeats):
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080078 yield io_opts
79
80
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020081def parse_opts(args):
82 parser = argparse.ArgumentParser()
83 parser.add_argument('--sizes', nargs="+", required=True)
84 parser.add_argument('--opers', nargs="+", required=True)
85 parser.add_argument('--cache-modes', nargs="+", required=True)
86 parser.add_argument('--concurrences', nargs="+", required=True)
87 parser.add_argument('--repeats', type=int, default=3)
88 parser.add_argument("--hdd-size", default="45G")
89 parser.add_argument("--tester-type", default="iozone")
90 parser.add_argument("--io-size", default=None)
koder aka kdanilov6e2ae792015-03-04 18:02:24 -080091
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020092 parser.add_argument("--direct-default-size", default="x1000")
93 parser.add_argument("--sync-default-size", default="x1000")
94 parser.add_argument("--async-default-size", default="r2")
95
96 return parser.parse_args(args[1:])
97
98
99def main(args):
100 opts = parse_opts(args)
101 for io_opts in make_load(opts):
102 print "python io.py --test-file /opt/xxx.bin " + io_opts
103
104if __name__ == "__main__":
105 exit(main(sys.argv))