summaryrefslogtreecommitdiff
path: root/gui/bench
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-13 15:10:16 -0300
committerGabriel Schneider <[email protected]>2026-11-13 15:10:16 -0300
commit9656105cb4c902213f281e658dd88286cc2df8ed (patch)
treedef1582280f4925688646dcfd14619f3c727b199 /gui/bench
parent4b76c25dc90417a9d6c3d4cd5af0dd3d4c087520 (diff)
downloadcomputeranim-9656105cb4c902213f281e658dd88286cc2df8ed.tar.gz
computeranim-9656105cb4c902213f281e658dd88286cc2df8ed.zip
debugger: link register hints and profile smooth native renderingHEADmain
Diffstat (limited to 'gui/bench')
-rw-r--r--gui/bench/RESULTS.md72
-rw-r--r--gui/bench/frames.py79
2 files changed, 151 insertions, 0 deletions
diff --git a/gui/bench/RESULTS.md b/gui/bench/RESULTS.md
index af16175..97e255a 100644
--- a/gui/bench/RESULTS.md
+++ b/gui/bench/RESULTS.md
@@ -213,3 +213,75 @@ Reloaded live session: GUI25666, d8 25705, recording
`Deoptimizer::New+4`, `0x7f99e5be3f74`, on `deoptimizer.cc:290`.
`rdx = 0x7f9984c00ffa` exactly matches the naturally optimized `jitWork` wrong-map
exit return; originating JS context uses guard `0x7f9984c00c14` at `jit.js:3`.
+
+## 2026-11-13: hints, frame timing and Tracy
+
+Register-value hints on the right of disassembly now share address hover and
+left/right-click behavior, using the displayed register width. Tests also caught
+and corrected the `di`/`bp`/`sp` and low-byte register aliases. Scalar hints remain
+inactive. Scroll reveals now finish exactly 200 ms after the latest target change,
+with a cubic ease-out and continuous retargeting; large address jumps still snap.
+
+Tracy is optional in Sketchbook and the GUI (`-Dtracy=CHECKOUT`), following
+Pardes's minimal Zig binding. Disabled builds omit the client. Host zones cover
+input, commands, frame construction, painting and presentation; GUI zones split
+panes, minimaps, recording refresh and overlays. `gui/bench/frames.py` captures a
+native session and exports the input script, trace, CSV and percentile summary.
+
+The main hitch was Vulkan allocation cleanup. Temporary SDL probes separated
+swapchain acquisition, submission, presentation and cleanup: freeing dedicated
+transfer-buffer allocations cost 25–48 ms in affected frames. The existing
+Sketchbook SDL patch already disables relocation. The same patch now allows
+small transfer buffers to share aligned allocations; mapped pointers retain their
+resource offsets. The patch fails if either expected source fragment changes.
+The probe sources were restored; no experimental renderer or shape cache ships.
+ASCII text also reuses white coverage masks across ink/opacity changes, while
+Unicode keeps painted glyphs, including emoji.
+
+Measured on this workstation (i7-11700, RTX 3050, native Vulkan, ReleaseFast,
+VSync, Tracy 0.13.4), excluding the first two seconds of cold loading:
+
+| Native scenario | Median frame interval | p95 | p99 | Maximum |
+| --- | ---: | ---: | ---: | ---: |
+| Original interaction script, before | 16.67 ms | 21.53 ms | 107.56 ms | 130.36 ms |
+| Same script, final renderer | 16.67 ms | 18.15 ms | 20.56 ms | 38.56 ms |
+| Reproducible harness, 2240×1260 / 100% | 16.67 ms | 18.47 ms | 21.79 ms | 37.11 ms |
+| Reproducible harness, 1440×900 / 100% | 16.65 ms | 18.24 ms | 19.53 ms | 22.83 ms |
+| Reproducible harness, 800×700 / 200% | 16.66 ms | 18.23 ms | 20.03 ms | 33.39 ms |
+
+The harness verifies 20 actual instruction steps while scrolling and opening
+lenses. Presentation in the final matching-script run stayed below 15.13 ms.
+These are CPU wall timings, including VSync/driver waits, not GPU timestamps.
+The result is approximately 60 Hz through ordinary interaction, not a guarantee
+that every frame meets 16.67 ms: cold font/source loading and occasional scheduling
+or stop-refresh frames still exceed it. Captures and the discarded probes remain
+under `/tmp/ztrace-perf/`; rerun the checked-in harness for durable new captures.
+
+Final checks passed: the GUI suite, shared canim renderer suite, Sketchbook suite,
+native hint/lens interactions, restart, fixed-backing 60–200% zoom and font-cache
+pixel tests. Independent code and native screenshot review found no remaining
+issues. The committed Sketchbook files also build in isolation from the checkout's
+unrelated pending GPU refactor. Normal GUI builds contain no Tracy client symbols.
+Sketchbook changes are committed as `d307463`.
+
+A fresh 1,000-step source-enabled benchmark (`steps.py`) measured capture median /
+p95 of 45.98 / 62.28 µs for C and 150.78 / 245.49 µs inside optimized `jitWork`.
+Controller round trips measured 62.43 / 94.60 µs and 180.00 / 288.76 µs respectively.
+This run naturally compiled through Maglev and TurboFan, then verified `wrong map`
+at the generated exit, `Deoptimizer::New`, `Runtime_NotifyDeoptimized`, and
+`Builtins_InterpreterEnterAtBytecode`, followed by the Ignition named-property
+bytecode handler. Its observed fallback was Ignition; default tiers were unchanged.
+
+Transition capture costs are separate: generated exit 351.74 µs, deoptimizer
+entry 224.82 µs, notification 245.63 µs, interpreter entry 404.48 µs, and first
+property handler 14.16 ms (including that handler's first capture/source work).
+Launch, natural warmup, initial symbols and first generated stop together took
+1.295 s. Results and recordings are in `/tmp/ztrace-perf/steps/`.
+
+Final restored live session: GUI PID45357, d8 PID46062, recording
+`/tmp/ztrace-gui-45357-18763846210612.ztrace`. Generated wrong-map exit
+`0x7f4062dc0ff6` was captured before stopping at `Deoptimizer::New+4`,
+`0x7f4004be3f74`, on `deoptimizer.cc:290`. Its `rdx = 0x7f4062dc0ffa`
+exactly matches the printed wrong-map return for naturally optimized `jitWork`.
+Originating JS context uses guard `0x7f4062dc0c14` at `jit.js:3`.
+The native window remains at that live stop with C++ and JS context visible.
diff --git a/gui/bench/frames.py b/gui/bench/frames.py
new file mode 100644
index 0000000..6131183
--- /dev/null
+++ b/gui/bench/frames.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+"""Capture native scrolling, lenses and live stepping with an opt-in Tracy build."""
+import argparse
+import csv
+import json
+from pathlib import Path
+import re
+import subprocess as sp
+
+ROOT = Path(__file__).resolve().parents[2]
+p = argparse.ArgumentParser(description=__doc__)
+p.add_argument('--tracy', type=Path, required=True, help='Tracy checkout with build-capture/ and build-csvexport/')
+p.add_argument('--gui', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace-gui')
+p.add_argument('--out', type=Path, required=True)
+p.add_argument('--size', default='2240x1260')
+p.add_argument('--zoom', type=int, default=100)
+a = p.parse_args()
+a.out = a.out.resolve()
+a.out.mkdir(parents=True, exist_ok=True)
+for tool in (a.gui, a.tracy / "build-capture/tracy-capture", a.tracy / "build-csvexport/tracy-csvexport"):
+ assert tool.is_file(), f"Missing executable: {tool}"
+target = a.out / 'segments'
+sp.run(['cc', '-g', '-O0', '-no-pie', str(ROOT / 'gui/targets/segments.c'), '-o', str(target)], check=True)
+symbols = dict((name, int(address, 16)) for address, name in re.findall(r'^([0-9a-f]+) \w (\w+)$', sp.check_output(['nm', '-n', str(target)], text=True), re.M))
+script = f'''console launch {target}
+await stops 1
+console break checkpoint
+console continue
+await execution 1
+console set zoom {a.zoom}
+frames 100
+console goto memory {hex(symbols['head'])}
+console set focus memory
+frames 30
+'''
+for _ in range(6):
+ for key in ('j', 'k'):
+ script += (f'key {key}\nframes 2\n' * 8)
+for _ in range(6):
+ script += f'console lens {hex(symbols["head"])}\nframes 15\nkey escape\nframes 3\n'
+for i in range(20):
+ script += f'key s\nawait execution {i + 2}\nframes 6\n'
+script += 'frames 60\nexpect execution 21\nexpect status stopped\n'
+(a.out / 'input.script').write_text(script)
+with (a.out / 'gui.log').open('w') as log, (a.out / 'capture.log').open('w') as cap:
+ app = sp.Popen([str(a.gui.resolve()), '--fresh', '--size', a.size, '--state', str(a.out / 'gui.state'), '--script', str(a.out / 'input.script')], stdout=log, stderr=log)
+ capture = sp.Popen([str(a.tracy / 'build-capture/tracy-capture'), '-o', str(a.out / 'frames.tracy'), '-f', '-s', '25'], stdout=cap, stderr=cap)
+ try:
+ assert app.wait(timeout=90) == 0, (a.out / 'gui.log').read_text()
+ assert capture.wait(timeout=30) == 0, (a.out / 'capture.log').read_text()
+ finally:
+ for proc in (app, capture):
+ if proc.poll() is None:
+ proc.terminate()
+ proc.wait()
+with (a.out / 'events.csv').open('w') as out:
+ sp.run([str(a.tracy / 'build-csvexport/tracy-csvexport'), '-u', str(a.out / 'frames.tracy')], stdout=out, check=True)
+values = {}
+starts = []
+with (a.out / 'events.csv').open() as f:
+ for row in csv.DictReader(f):
+ at = int(row['ns_since_start']) / 1e9
+ if at < 2:
+ continue # Cold font/source loading is separate from warm interaction.
+ name = row['name']
+ if name not in ('frame', 'draw', 'paint commands', 'present', 'trace refresh'):
+ continue
+ values.setdefault(name, []).append(int(row['exec_time_ns']) / 1e6)
+ if name == 'frame':
+ starts.append(at)
+starts.sort()
+values['frame interval'] = [(b - a) * 1000 for a, b in zip(starts, starts[1:])]
+result = {}
+for name, v in values.items():
+ v.sort()
+ assert v, 'No Tracy frames: rebuild with -Dtracy=CHECKOUT'
+ result[name] = dict(samples=len(v), **{label: v[min(len(v)-1, int(len(v)*q))] for label, q in [('median_ms', .5), ('p95_ms', .95), ('p99_ms', .99), ('max_ms', 1)]}, over_20ms=sum(x > 20 for x in v))
+(a.out / 'results.json').write_text(json.dumps(result, indent=2) + '\n')
+print(json.dumps(result, indent=2))