aboutsummaryrefslogtreecommitdiff
path: root/scripts/simplebench/bench-backup.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-05-21 12:02:34 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-05-21 12:02:34 +0100
commit6c769690ac845fa62642a5f93b4e4bd906adab95 (patch)
tree39efec1a186c28786874160db4f27d7c75bfb1d7 /scripts/simplebench/bench-backup.py
parentda9076f323d1470c65634893aa2427987699d4f1 (diff)
parente34bd02694026722410b80cee02ab7f33f893e9b (diff)
Merge remote-tracking branch 'remotes/vsementsov/tags/pull-simplebench-2021-05-04' into staging
scripts/simplebench improvements for 2021-05-04 # gpg: Signature made Tue 04 May 2021 09:45:15 BST # gpg: using RSA key 8B9C26CDB2FD147C880E86A1561F24C1F19F79FB # gpg: Good signature from "Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 8B9C 26CD B2FD 147C 880E 86A1 561F 24C1 F19F 79FB * remotes/vsementsov/tags/pull-simplebench-2021-05-04: MAINTAINERS: update Benchmark util: add git tree simplebench/bench-backup: add --drop-caches argument simplebench/bench-backup: add --count and --no-initial-run simplebench/bench-backup: support qcow2 source files simplebench/bench_block_job: handle error in BLOCK_JOB_COMPLETED simplebench/bench-backup: add target-cache argument simplebench/bench-backup: add --compressed option simplebench: bench_one(): support count=1 simplebench: bench_one(): add slow_limit argument Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/simplebench/bench-backup.py')
-rwxr-xr-xscripts/simplebench/bench-backup.py95
1 files changed, 78 insertions, 17 deletions
diff --git a/scripts/simplebench/bench-backup.py b/scripts/simplebench/bench-backup.py
index 33a1ecfefa..5a0675c593 100755
--- a/scripts/simplebench/bench-backup.py
+++ b/scripts/simplebench/bench-backup.py
@@ -23,7 +23,7 @@ import json
import simplebench
from results_to_text import results_to_text
-from bench_block_job import bench_block_copy, drv_file, drv_nbd
+from bench_block_job import bench_block_copy, drv_file, drv_nbd, drv_qcow2
def bench_func(env, case):
@@ -37,29 +37,56 @@ def bench_func(env, case):
def bench(args):
test_cases = []
- sources = {}
- targets = {}
- for d in args.dir:
- label, path = d.split(':') # paths with colon not supported
- sources[label] = drv_file(path + '/test-source')
- targets[label] = drv_file(path + '/test-target')
+ # paths with colon not supported, so we just split by ':'
+ dirs = dict(d.split(':') for d in args.dir)
+ nbd_drv = None
if args.nbd:
nbd = args.nbd.split(':')
host = nbd[0]
port = '10809' if len(nbd) == 1 else nbd[1]
- drv = drv_nbd(host, port)
- sources['nbd'] = drv
- targets['nbd'] = drv
+ nbd_drv = drv_nbd(host, port)
for t in args.test:
src, dst = t.split(':')
- test_cases.append({
- 'id': t,
- 'source': sources[src],
- 'target': targets[dst]
- })
+ if src == 'nbd' and dst == 'nbd':
+ raise ValueError("Can't use 'nbd' label for both src and dst")
+
+ if (src == 'nbd' or dst == 'nbd') and not nbd_drv:
+ raise ValueError("'nbd' label used but --nbd is not given")
+
+ if src == 'nbd':
+ source = nbd_drv
+ elif args.qcow2_sources:
+ source = drv_qcow2(drv_file(dirs[src] + '/test-source.qcow2'))
+ else:
+ source = drv_file(dirs[src] + '/test-source')
+
+ if dst == 'nbd':
+ test_cases.append({'id': t, 'source': source, 'target': nbd_drv})
+ continue
+
+ if args.target_cache == 'both':
+ target_caches = ['direct', 'cached']
+ else:
+ target_caches = [args.target_cache]
+
+ for c in target_caches:
+ o_direct = c == 'direct'
+ fname = dirs[dst] + '/test-target'
+ if args.compressed:
+ fname += '.qcow2'
+ target = drv_file(fname, o_direct=o_direct)
+ if args.compressed:
+ target = drv_qcow2(target)
+
+ test_id = t
+ if args.target_cache == 'both':
+ test_id += f'({c})'
+
+ test_cases.append({'id': test_id, 'source': source,
+ 'target': target})
binaries = [] # list of (<label>, <path>, [<options>])
for i, q in enumerate(args.env):
@@ -106,6 +133,13 @@ def bench(args):
elif opt.startswith('max-workers='):
x_perf['max-workers'] = int(opt.split('=')[1])
+ backup_options = {}
+ if x_perf:
+ backup_options['x-perf'] = x_perf
+
+ if args.compressed:
+ backup_options['compress'] = True
+
if is_mirror:
assert not x_perf
test_envs.append({
@@ -117,11 +151,13 @@ def bench(args):
test_envs.append({
'id': f'backup({label})\n' + '\n'.join(opts),
'cmd': 'blockdev-backup',
- 'cmd-options': {'x-perf': x_perf} if x_perf else {},
+ 'cmd-options': backup_options,
'qemu-binary': path
})
- result = simplebench.bench(bench_func, test_envs, test_cases, count=3)
+ result = simplebench.bench(bench_func, test_envs, test_cases,
+ count=args.count, initial_run=args.initial_run,
+ drop_caches=args.drop_caches)
with open('results.json', 'w') as f:
json.dump(result, f, indent=4)
print(results_to_text(result))
@@ -163,5 +199,30 @@ default port 10809). Use it in tests, label is "nbd"
p.add_argument('--test', nargs='+', help='''\
Tests, in form source-dir-label:target-dir-label''',
action=ExtendAction)
+ p.add_argument('--compressed', help='''\
+Use compressed backup. It automatically means
+automatically creating qcow2 target with
+lazy_refcounts for each test run''', action='store_true')
+ p.add_argument('--qcow2-sources', help='''\
+Use test-source.qcow2 images as sources instead of
+test-source raw images''', action='store_true')
+ p.add_argument('--target-cache', help='''\
+Setup cache for target nodes. Options:
+ direct: default, use O_DIRECT and aio=native
+ cached: use system cache (Qemu default) and aio=threads (Qemu default)
+ both: generate two test cases for each src:dst pair''',
+ default='direct', choices=('direct', 'cached', 'both'))
+
+ p.add_argument('--count', type=int, default=3, help='''\
+Number of test runs per table cell''')
+
+ # BooleanOptionalAction helps to support --no-initial-run option
+ p.add_argument('--initial-run', action=argparse.BooleanOptionalAction,
+ help='''\
+Do additional initial run per cell which doesn't count in result,
+default true''')
+
+ p.add_argument('--drop-caches', action='store_true', help='''\
+Do "sync; echo 3 > /proc/sys/vm/drop_caches" before each test run''')
bench(p.parse_args())