diff options
Diffstat (limited to 'gui/bench/steps.py')
| -rw-r--r-- | gui/bench/steps.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/gui/bench/steps.py b/gui/bench/steps.py index f97efed..166fa90 100644 --- a/gui/bench/steps.py +++ b/gui/bench/steps.py @@ -17,6 +17,7 @@ p.add_argument('--d8', type=Path, required=True) p.add_argument('--ztrace', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace') p.add_argument('--out', type=Path, default=Path('/tmp/ztrace-step-bench')) p.add_argument('--steps', type=int, default=1000) +p.add_argument('--jit-source', action='store_true', help='Measure with V8 JIT symbols and source lines loaded') a = p.parse_args() assert a.steps > 0 a.out.mkdir(parents=True, exist_ok=True) @@ -24,6 +25,9 @@ a.out = a.out.resolve() a.d8 = a.d8.resolve() small = a.out / 'loop' subprocess.run(['cc', '-g', '-O0', str(ROOT / 'gui/targets/loop.c'), '-o', str(small)], check=True) +js = a.out / f'bench-jit-{os.getpid()}.js' +if a.jit_source: + js.write_bytes((ROOT / 'gui/targets/jit.js').read_bytes()) class Controller: @@ -31,7 +35,7 @@ class Controller: self.log = (a.out / (name + '.log')).open('w+') self.process = subprocess.Popen( [str(a.ztrace.resolve()), 'serve', str(a.out / (name + '.ztrace')), '--', *argv], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=self.log, bufsize=0) + cwd=a.out, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=self.log, bufsize=0) self.pending = b'' def read(self): @@ -76,9 +80,11 @@ def summary(ns): results = {} for name, argv in [('c', [str(small)]), ('v8', [str(a.d8), '--allow-natives-syntax', '--no-concurrent-recompilation', '--no-maglev', '--print-opt-code', - '--print-opt-code-filter=jitWork', str(ROOT / 'gui/targets/jit.js')])]: + '--print-opt-code-filter=jitWork', *(['--gdbjit', '--gdbjit-dump', '--gdbjit-dump-filter=jitWork', js.name] + if a.jit_source else [str(ROOT / 'gui/targets/jit.js')])])]: start = time.perf_counter_ns() c = Controller(name, argv) + elf = None try: assert c.read()['status'] == 'stopped' entry_ns = time.perf_counter_ns() - start @@ -107,6 +113,10 @@ for name, argv in [('c', [str(small)]), ('v8', [str(a.d8), '--allow-natives-synt if name == 'v8': stepped = c.command('step') assert stepped['reason'] == 'step' and stepped['pc'] != address, stepped + if a.jit_source: + elf, = Path('/tmp').glob('elfdumpjitWork ' + js.name + ':*.o') + imported = c.command('symbols ' + str(elf)) + assert imported['pc'] == stepped['pc'], imported core, wall = [], [] for _ in range(a.steps): start_step = time.perf_counter_ns() @@ -116,11 +126,18 @@ for name, argv in [('c', [str(small)]), ('v8', [str(a.d8), '--allow-natives-synt assert reply['reason'] == 'step', reply results[name] = dict(steps=a.steps, entry_ms=entry_ns / 1e6, first_break_ms=first_break_ns / 1e6, capture=summary(core), roundtrip=summary(wall)) + if name == 'v8': + results[name]['jit_source'] = a.jit_source print(name, json.dumps(results[name]), flush=True) finally: c.close() + if elf is not None: + elf.unlink(missing_ok=True) if name == 'v8': shown = subprocess.run([str(a.ztrace.resolve()), 'show', str(a.out / 'v8.ztrace'), '-1'], check=True, capture_output=True, text=True) - assert f"thread {reply['tid']}" in shown.stdout.splitlines(), 'JIT stop inherited a stale native source line' + if a.jit_source: + assert str(js) + ':' in shown.stdout, 'JIT source line missing' + else: + assert f"thread {reply['tid']}" in shown.stdout.splitlines(), 'JIT stop inherited a stale native source line' (a.out / 'results.json').write_text(json.dumps(results, indent=2) + '\n') |
