summaryrefslogtreecommitdiff
path: root/gui/bench
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-13 01:24:16 -0300
committerGabriel Schneider <[email protected]>2026-11-13 01:34:46 -0300
commit5a40dca5adb6e9e650f55f3ec6f254a13bf50493 (patch)
tree5fdffebd75ed3fbac1eae5dec0a3f2d491450342 /gui/bench
parent4b4113a0217ee27c78e7efddb66ff5a455d49083 (diff)
downloadcomputeranim-5a40dca5adb6e9e650f55f3ec6f254a13bf50493.tar.gz
computeranim-5a40dca5adb6e9e650f55f3ec6f254a13bf50493.zip
debugger: align source and add rich Vim-style navigation
Diffstat (limited to 'gui/bench')
-rw-r--r--gui/bench/RESULTS.md88
-rw-r--r--gui/bench/redraw.py34
-rw-r--r--gui/bench/steps.py23
3 files changed, 114 insertions, 31 deletions
diff --git a/gui/bench/RESULTS.md b/gui/bench/RESULTS.md
index d24659b..89f0d78 100644
--- a/gui/bench/RESULTS.md
+++ b/gui/bench/RESULTS.md
@@ -1,6 +1,6 @@
# Debug V8 versus a small C target
-Measured locally on 2026-11-12, Linux 7.2.11-arch1-1, Intel i7-11700,
+Measured locally on 2026-11-13, Linux 7.2.11-arch1-1, Intel i7-11700,
Zig 0.17.0, ReleaseFast controller. The targets were a `cc -g -O0` C loop
and **unoptimized debug V8**, not release d8. Both used the same controller:
512 stack bytes, 24 disassembled instructions and telescope depth 2, with a
@@ -13,22 +13,22 @@ Final controller run:
python3 gui/bench/steps.py \
--d8 /tmp/computeranim-v8-debug-remote/d8 \
--ztrace zig-out/bin/ztrace \
- --out /tmp/ztrace-step-bench-cleared
+ --out /tmp/ztrace-step-bench-ui
```
| 1,000 instruction steps | C | Debug V8 / generated JS |
| --- | ---: | ---: |
-| Capture + flush, median | 35.73 µs | 38.47 µs |
-| Capture + flush, p95 | 45.13 µs | 59.18 µs |
-| Controller round trip, median | 46.94 µs | 49.53 µs |
-| Controller round trip, p95 | 59.23 µs | 73.00 µs |
-| Controller round trip, maximum | 310.72 µs | 381.48 µs |
-| Launch through first requested breakpoint | 9.50 ms | 901.84 ms |
+| Capture + flush, median | 37.48 µs | 38.43 µs |
+| Capture + flush, p95 | 54.37 µs | 52.48 µs |
+| Controller round trip, median | 49.49 µs | 49.48 µs |
+| Controller round trip, p95 | 72.46 µs | 68.31 µs |
+| Controller round trip, maximum | 553.21 µs | 364.10 µs |
+| Launch through first requested breakpoint | 5.98 ms | 938.49 ms |
This supports comparable steady instruction-step cost for these workloads.
It does not claim that V8 starts as quickly as a small program, or that all C++
-source/DWARF operations have this cost. The earlier 1,000-step run measured
-39.09 / 44.42 µs capture medians and 53.69 / 60.57 µs round-trip medians for
+source/DWARF operations have this cost. The previous 1,000-step run measured
+35.73 / 38.47 µs capture medians and 46.94 / 49.53 µs round-trip medians for
C / V8. Scheduling and cache state affect these microsecond measurements; no
CPU isolation or filesystem-cache dropping was used. GUI presentation is not
included in the controller timings.
@@ -42,9 +42,23 @@ the recording no longer reports the previous native source line. The loop
address is read from V8's own output; the harness fails rather than guesses if
a different V8 compiler allocates different registers.
-The raw records, logs and JSON results are in `/tmp/ztrace-step-bench-cleared`.
+The raw records, logs and JSON results are in `/tmp/ztrace-step-bench-ui`.
The script is the durable reproducer; `/tmp` artifacts are not permanent.
+With JIT source information loaded, the final 1,000-step run remained comparable:
+
+| Source-enabled run | C | Debug V8 / generated JS |
+| --- | ---: | ---: |
+| Capture + flush, median | 36.60 µs | 37.76 µs |
+| Capture + flush, p95 | 46.78 µs | 46.35 µs |
+| Controller round trip, median | 48.04 µs | 48.84 µs |
+| Controller round trip, p95 | 60.97 µs | 63.83 µs |
+
+Reproduce with `--jit-source --out /tmp/ztrace-step-bench-source` added to the
+command above. This run imports the real JIT ELF before sampling and checks the
+final recording retains JavaScript source information. The initial import is
+excluded from steady stepping, just as executable startup is excluded.
+
## V8 provenance
The user's remote Arch build host (`chaincli-box`) has the existing checkout at
@@ -68,10 +82,19 @@ and smoke-tested locally.
## Checks
-The GUI's real-target script exercises launch, a named breakpoint, continue,
-keyboard and mouse instruction stepping, source stepping, pause during execution,
-and browsing history back to live. The core tests additionally check pause
-signal suppression and source stepping without line information.
+The GUI's real-target script exercises launch, a named breakpoint through the
+Vim command bar, continue, keyboard and mouse instruction stepping, source
+stepping, pause during execution and browsing history back to live. It also
+checks fractional scrolling, pane histories, Mouse4/5 through the actual
+pointer handler, semantic right-clicks, minimap dragging and animated lenses.
+Native-window checks cover keyboard stepping, pane focus, scrolling and command
+entry. Raw hardware Mouse4/5 injection was not performed.
+
+`gui/test/inspection.py` checks bounded read-only code/memory inspection against
+C and debug V8: RIP stays unchanged, invalid counts are rejected, and subsequent
+stepping still works. With `--d8`, it imports V8's real GDB JIT ELF and asserts
+that source line 6 of the JavaScript fixture appears in the recorded instruction
+metadata. The line mapping comes from V8's DWARF line program.
The root suite had two failures before this work; they remain in the existing
loader/syscall formatting and watch/string assertions. The new debugger tests
@@ -86,17 +109,26 @@ animation design, checked strike/highlight/settled frames, and approved the
final native window. The checked-in GUI test asserts that the stack highlight
changes between strike and settled screenshots, as well as exercising controls.
-At 1920×1080, an approximate headless redraw measurement was **1.23 ms/frame
-for C and 2.41 ms/frame for V8**. This subtracts the median elapsed time of
-30-frame runs from 330-frame runs (three repeats each), then divides by 300.
-Both opened the corresponding 1,000-step recording. V8 displayed 24 instruction
-rows while C displayed 10; this is a whole-view cost, not an equal-row renderer
-comparison. It excludes live trace reopening and display presentation latency.
-Raw timings are in `/tmp/ztrace-gui-redraw-results.json`.
+At 2240×1260, an approximate headless redraw measurement was **3.55 ms/frame
+for C and 4.28 ms/frame for V8**, including source/disassembly, registers,
+stack, memory and cached content minimaps. `gui/bench/redraw.py` subtracts the
+median elapsed time of 30-frame runs from 330-frame runs (three repeats each),
+then divides by 300. Both opened their corresponding source-enabled 1,000-step recording;
+this is a whole-view cost, not an equal-row renderer comparison. It excludes
+live trace reopening and display presentation latency. Raw timings are in
+`/tmp/ztrace-gui-redraw-source.json`. The previous, smaller 1920×1080 view measured
+1.23 / 2.41 ms/frame for C / V8.
+
+The complete animation gallery and shared renderer tests passed after the
+library changes. Existing applications retain their organization: the GUI uses
+shared source preparation/alignment, row drawing, address hit geometry and
+minimap drawing instead of maintaining a second renderer.
-The final native session was verified with d8 PID 2502490 in Linux tracing-stop
-state and recorded RIP `0x7f09921c0196`: breakpoint 2 on `add r8d, r9d`, offset
-`0x156` inside TurboFan-generated `jitWork`. It is left open in the GUI. The
-recording is `/tmp/ztrace-gui-2502452-357545622054931.ztrace`; the screenshot is
-`/tmp/ztrace-v8-live-final.png`. These addresses and PIDs describe this session
-only. The complete animation gallery was not re-rendered.
+The final native window was independently approved with debug d8 PID 2536162
+in Linux tracing-stop state at breakpoint 1, RIP `0x7f6ee00001a2`: `jbe`, offset
+`0x162` inside TurboFan-generated `jitWork`, mapped by V8's line table to the
+body at `gui/targets/jit.js:6`. Both the source-to-PC and branch-to-target arrows
+are visible. The GUI remains open. The recording is
+`/tmp/ztrace-gui-2536121-364024192152453.ztrace`; the screenshot is
+`/tmp/ztrace-v8-final-reviewed.png`. Addresses and PIDs identify this session
+only. Other test windows were closed.
diff --git a/gui/bench/redraw.py b/gui/bench/redraw.py
new file mode 100644
index 0000000..84c1314
--- /dev/null
+++ b/gui/bench/redraw.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+"""Estimate steady GUI redraw cost by subtracting matched short and long runs."""
+import argparse
+import json
+from pathlib import Path
+import statistics
+import subprocess
+import tempfile
+import time
+
+ROOT = Path(__file__).resolve().parents[2]
+p = argparse.ArgumentParser(description=__doc__)
+p.add_argument('--gui', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace-gui')
+p.add_argument('--c', type=Path, required=True)
+p.add_argument('--v8', type=Path, required=True)
+p.add_argument('--out', type=Path, default=Path('/tmp/ztrace-gui-redraw-ui.json'))
+a = p.parse_args()
+results = {}
+with tempfile.TemporaryDirectory(prefix='ztrace-redraw-') as directory:
+ work = Path(directory)
+ for name, recording in [('c', a.c), ('v8', a.v8)]:
+ samples = {30: [], 330: []}
+ for _ in range(3):
+ for count in samples:
+ script = work / 'draw.script'
+ script.write_text(f'console open {recording.resolve()}\nframes {count}\n')
+ start = time.perf_counter_ns()
+ subprocess.run([str(a.gui.resolve()), '--headless', '--fresh', '--state', str(work / 'draw.state'),
+ '--script', str(script)], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True)
+ samples[count].append((time.perf_counter_ns() - start) / 1e6)
+ results[name] = dict(elapsed_ms=samples,
+ incremental_frame_ms=(statistics.median(samples[330]) - statistics.median(samples[30])) / 300)
+ print(name, json.dumps(results[name]), flush=True)
+a.out.write_text(json.dumps(results, indent=2) + '\n')
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')