koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 1 | import sys |
| 2 | import argparse |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 3 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 4 | from disk_perf_test_tool.utils import ssize2b |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 5 | |
| 6 | |
| 7 | def make_list(x): |
| 8 | if not isinstance(x, (list, tuple)): |
| 9 | return [x] |
| 10 | return x |
| 11 | |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 12 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 13 | def make_load(settings): |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 14 | |
| 15 | iodepth = 1 |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 16 | 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 kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 20 | |
| 21 | # filter out too slow options |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 22 | if bsize in "1k 4k" and cache_mode == "a": |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 23 | continue |
| 24 | |
| 25 | # filter out sync reads |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 26 | if oper in "read randread" and cache_mode == "s": |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 27 | continue |
| 28 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 29 | 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 kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 35 | else: |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 36 | 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 kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 46 | mmax_f = ssize2b(settings.hdd_size) / \ |
| 47 | (int(conc) * ssize2b(bsize)) |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 48 | |
| 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 kdanilov | ce5444f | 2015-03-14 09:19:02 +0200 | [diff] [blame] | 60 | else: |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 61 | 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 kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 67 | |
| 68 | # size_sync_opts = get_file_size_opts(sync_type) |
| 69 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 70 | io_opts = "--type {0} ".format(settings.tester_type) |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 71 | 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 kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 77 | for i in range(settings.repeats): |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 78 | yield io_opts |
| 79 | |
| 80 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 81 | def 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 kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 91 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 92 | 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 | |
| 99 | def 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 | |
| 104 | if __name__ == "__main__": |
| 105 | exit(main(sys.argv)) |