test.py/bench.py: Limited -d/--disk and -t/--trace to one thread

It doesn't really make sense to write to disk/trace files with multiple
threads, the result usually ends up clobbered and useless.

If we only pass disk/trace files to the first thread, the result is at
at least useable, even if it only represents 1/j tests.

This is actually quite a nice way to sample filesystem images in
multithreaded tests.

As a side effect, this also changes test.py/bench.py to no longer pass
-d/--disk or -t/--trace to runner queries, which is probably a good
thing? These should be ignored in queries anyways.
This commit is contained in:
Christopher Haster
2025-01-17 02:40:05 -06:00
parent 624eb1ad52
commit 5aada6f54a
2 changed files with 60 additions and 52 deletions
+14 -10
View File
@@ -649,7 +649,7 @@ def compile(bench_paths, **args):
f.writeln()
def find_runner(runner, id=None, **args):
def find_runner(runner, id=None, main=True, **args):
cmd = runner.copy()
# run under some external command?
@@ -683,6 +683,10 @@ def find_runner(runner, id=None, **args):
cmd.append('--define-depth=%s' % args['define_depth'])
if args.get('all'):
cmd.append('-a')
# only one thread should write to disk/trace, otherwise the output
# ends up clobbered and useless
if main:
if args.get('disk'):
cmd.append('-d%s' % args['disk'])
if args.get('trace'):
@@ -716,7 +720,7 @@ def find_runner(runner, id=None, **args):
return cmd
def find_perms(runner, bench_ids=[], **args):
runner_ = find_runner(runner, **args)
runner_ = find_runner(runner, main=False, **args)
case_suites = {}
expected_case_perms = co.OrderedDict()
expected_perms = 0
@@ -790,7 +794,7 @@ def find_perms(runner, bench_ids=[], **args):
total_perms)
def find_path(runner, id, **args):
runner_ = find_runner(runner, id, **args)
runner_ = find_runner(runner, id, main=False, **args)
path = None
# query from runner
cmd = runner_ + ['--list-case-paths', id]
@@ -818,7 +822,7 @@ def find_path(runner, id, **args):
return path
def find_defines(runner, id, **args):
runner_ = find_runner(runner, id, **args)
runner_ = find_runner(runner, id, main=False, **args)
# query permutation defines from runner
cmd = runner_ + ['--list-permutation-defines', id]
if args.get('verbose'):
@@ -914,7 +918,7 @@ def find_ids(runner, bench_ids=[], **args):
def list_(runner, bench_ids=[], **args):
cmd = find_runner(runner, **args)
cmd = find_runner(runner, main=False, **args)
cmd.extend(find_ids(runner, bench_ids, **args))
if args.get('summary'): cmd.append('--summary')
@@ -1151,7 +1155,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
list(last_stdout),
last_assert)
def run_job(start=None, step=None):
def run_job(main=True, start=None, step=None):
nonlocal failed_perms
nonlocal failures
nonlocal killed
@@ -1160,10 +1164,10 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
start = start or 0
step = step or 1
while start < total_perms:
runner_ = find_runner(runner, **args)
runner_ = find_runner(runner, main=main, **args)
if args.get('isolate') or args.get('valgrind'):
runner_.append('-s%s,%s,%s' % (start, start+step, step))
else:
elif start != 0 or step != 1:
runner_.append('-s%s,,%s' % (start, step))
runner_.extend(bench_ids)
@@ -1205,11 +1209,11 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
if 'jobs' in args:
for job in range(args['jobs']):
runners.append(th.Thread(
target=run_job, args=(job, args['jobs']),
target=run_job, args=(job == 0, job, args['jobs']),
daemon=True))
else:
runners.append(th.Thread(
target=run_job, args=(None, None),
target=run_job, args=(True, None, None),
daemon=True))
def print_update(done):
+14 -10
View File
@@ -667,7 +667,7 @@ def compile(test_paths, **args):
f.writeln()
def find_runner(runner, id=None, **args):
def find_runner(runner, id=None, main=True, **args):
cmd = runner.copy()
# run under some external command?
@@ -703,6 +703,10 @@ def find_runner(runner, id=None, **args):
cmd.append('-P%s' % args['powerloss'])
if args.get('all'):
cmd.append('-a')
# only one thread should write to disk/trace, otherwise the output
# ends up clobbered and useless
if main:
if args.get('disk'):
cmd.append('-d%s' % args['disk'])
if args.get('trace'):
@@ -736,7 +740,7 @@ def find_runner(runner, id=None, **args):
return cmd
def find_perms(runner, test_ids=[], **args):
runner_ = find_runner(runner, **args)
runner_ = find_runner(runner, main=False, **args)
case_suites = {}
expected_case_perms = co.OrderedDict()
expected_perms = 0
@@ -810,7 +814,7 @@ def find_perms(runner, test_ids=[], **args):
total_perms)
def find_path(runner, id, **args):
runner_ = find_runner(runner, id, **args)
runner_ = find_runner(runner, id, main=False, **args)
path = None
# query from runner
cmd = runner_ + ['--list-case-paths', id]
@@ -838,7 +842,7 @@ def find_path(runner, id, **args):
return path
def find_defines(runner, id, **args):
runner_ = find_runner(runner, id, **args)
runner_ = find_runner(runner, id, main=False, **args)
# query permutation defines from runner
cmd = runner_ + ['--list-permutation-defines', id]
if args.get('verbose'):
@@ -934,7 +938,7 @@ def find_ids(runner, test_ids=[], **args):
def list_(runner, test_ids=[], **args):
cmd = find_runner(runner, **args)
cmd = find_runner(runner, main=False, **args)
cmd.extend(find_ids(runner, test_ids, **args))
if args.get('summary'): cmd.append('--summary')
@@ -1123,7 +1127,7 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
list(last_stdout),
last_assert)
def run_job(start=None, step=None):
def run_job(main=True, start=None, step=None):
nonlocal failed_perms
nonlocal failures
nonlocal killed
@@ -1132,10 +1136,10 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
start = start or 0
step = step or 1
while start < total_perms:
runner_ = find_runner(runner, **args)
runner_ = find_runner(runner, main=main, **args)
if args.get('isolate') or args.get('valgrind'):
runner_.append('-s%s,%s,%s' % (start, start+step, step))
else:
elif start != 0 or step != 1:
runner_.append('-s%s,,%s' % (start, step))
runner_.extend(test_ids)
@@ -1189,11 +1193,11 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args):
if 'jobs' in args:
for job in range(args['jobs']):
runners.append(th.Thread(
target=run_job, args=(job, args['jobs']),
target=run_job, args=(job == 0, job, args['jobs']),
daemon=True))
else:
runners.append(th.Thread(
target=run_job, args=(None, None),
target=run_job, args=(True, None, None),
daemon=True))
def print_update(done):