fix indentation and debug: add pipeline counters
Validate and Test / validate-patches (push) Failing after 13s

This commit is contained in:
2026-06-24 04:07:17 -07:00
parent 89da97c637
commit 979e89e305
+33 -23
View File
@@ -82,6 +82,9 @@ def main():
fps_sample_frames = 0 fps_sample_frames = 0
events_processed = 0 events_processed = 0
raw_packets = 0 raw_packets = 0
semicolon_hits = 0
midi_matched = 0
changed_true = 0
while True: while True:
now = time.monotonic() now = time.monotonic()
@@ -104,37 +107,41 @@ def main():
pass pass
while b";" in buf: while b";" in buf:
semicolon_hits += 1
raw_msg, buf = buf.split(b";", 1) raw_msg, buf = buf.split(b";", 1)
msg = raw_msg.decode().strip() msg = raw_msg.decode().strip()
parts = msg.split() parts = msg.split()
if not parts: if not parts:
print(f"[viz] empty parts: {msg!r}", flush=True)
continue continue
if parts[0] != "midi": if parts[0] != "midi":
print(f"[viz] skipping: {msg!r}", flush=True) print(f"[viz] not midi: {msg!r}", flush=True)
continue continue
if len(parts) < 3: if len(parts) < 3:
print(f"[viz] too short: {parts}", flush=True) print(f"[viz] too short: {parts}", flush=True)
continue continue
status = int(parts[1]) midi_matched += 1
note = int(parts[2]) status = int(parts[1])
vel = int(parts[3]) if len(parts) >= 4 else 0 note = int(parts[2])
msg_type = status & 0xF0 vel = int(parts[3]) if len(parts) >= 4 else 0
changed = False msg_type = status & 0xF0
if msg_type == 0x90 and vel > 0: changed = False
if note not in active_notes: if msg_type == 0x90 and vel > 0:
active_notes.add(note) if note not in active_notes:
changed = True active_notes.add(note)
elif msg_type == 0x80 or (msg_type == 0x90 and vel == 0): changed = True
if note in active_notes: elif msg_type == 0x80 or (msg_type == 0x90 and vel == 0):
active_notes.discard(note) if note in active_notes:
changed = True active_notes.discard(note)
if changed: changed = True
events_processed += 1 if changed:
params = render(active_notes) changed_true += 1
if params != last_sent_params: events_processed += 1
msg_id = (msg_id + 1) % 65535 params = render(active_notes)
pending_bytes = packer.pack([0, msg_id, "draw_frame", params]) if params != last_sent_params:
last_sent_params = params msg_id = (msg_id + 1) % 65535
pending_bytes = packer.pack([0, msg_id, "draw_frame", params])
last_sent_params = params
# Try to send pending frame — no POLLOUT dependency # Try to send pending frame — no POLLOUT dependency
if pending_bytes is not None: if pending_bytes is not None:
@@ -160,14 +167,14 @@ def main():
if now - stats_last_write >= 2.0: if now - stats_last_write >= 2.0:
fps = fps_sample_frames / (now - fps_sample_start) if (now - fps_sample_start) > 0 else 0 fps = fps_sample_frames / (now - fps_sample_start) if (now - fps_sample_start) > 0 else 0
_write_stats(frames_sent, frames_dropped, fps, len(active_notes), events_processed, bytes_received, raw_packets) _write_stats(frames_sent, frames_dropped, fps, len(active_notes), events_processed, bytes_received, raw_packets, semicolon_hits, midi_matched, changed_true)
stats_last_write = now stats_last_write = now
fps_sample_start = now fps_sample_start = now
fps_sample_frames = 0 fps_sample_frames = 0
events_processed = 0 events_processed = 0
def _write_stats(sent, dropped, fps, active_count, events, bytes_rcv, packets): def _write_stats(sent, dropped, fps, active_count, events, bytes_rcv, packets, semi, matched, changed):
import json import json
try: try:
with open(STATS_FILE, "w") as f: with open(STATS_FILE, "w") as f:
@@ -179,6 +186,9 @@ def _write_stats(sent, dropped, fps, active_count, events, bytes_rcv, packets):
"midi_events": events, "midi_events": events,
"bytes_received": bytes_rcv, "bytes_received": bytes_rcv,
"raw_packets": packets, "raw_packets": packets,
"semicolon_hits": semi,
"midi_matched": matched,
"changed_true": changed,
"ts": time.time() "ts": time.time()
}, f) }, f)
except OSError: except OSError: