You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PERF REGRESSION (merged #71): unconditional post-ServerHello drain costs ~70 s on UCI — shipped handshake 51 s → 125 s @48 MHz #73
PR #71's post-ServerHello drain (src/tls13.s, ldy #8 / ldx #250 = 2,000 net_poll calls) is unconditional, but its cost is wildly backend-dependent.
Measured on real C64 Ultimate hardware (10.53.21.158, onchip UCI build, TURBO_MHZ=48, local listener):
~2.5x regression on the shipped/packaged path. ~70 s of that is the drain
(~37 ms × 2,000 polls); ~4.5 s is #69's on-chip X25519 rows at this clock
(expected, CPU-bound, scales with turbo).
Why the cost differs so much per backend
The drain exists because ip65 ACKs only when polled — the fix for the
server-flight tail sitting unACKed through a multi-minute crypto stall. On
ip65 a net_poll is a cheap NIC pump.
On UCI, net_poll is a full firmware command round-trip: SOCKET_READ via uci_wait_not_busy → uci_begin_cmd → 4 × uci_put_byte → uci_push_wait → uci_check_err → header read → uci_drain_resp + uci_drain_status + uci_ack — ~25 fenced register accesses plus FPGA turnaround. Fences alone
are only ~2.8 ms/poll at 48 MHz; the observed ~37 ms/poll is dominated by
clock-invariant firmware turnaround inside the spin-waits.
And critically: UCI firmware ACKs autonomously regardless of C64 polling —
which is exactly why the original unACKed-tail bug never appeared on UCI. So
on UCI the 2,000 polls buy nothing and cost ~70 s.
My error
I reviewed and approved #71 with the note "estimated ~1 s of fenced polls on
UCI turbo — worth re-validating on Ultimate hardware." The estimate counted
fence time only and ignored firmware turnaround; it was off by ~70x. The
in-code budget comment reasons about ip65 poll costs exclusively.
Worth noting this also violates the spirit of the rule c64-lib-contract SPEC
§13.4 standardizes (bounded waits must be wall-clock-based, not
iteration-counted) — an iteration budget calibrated on one backend's poll
cost is precisely the failure mode §13.4 exists to prevent.
Fix direction
Per-backend drain budget: ip65 keeps its (validated) 2,000; UCI drops to a
small hedge value, since firmware autonomy makes the drain's ACK purpose moot
there. A wall-clock/idle-detection drain (poll until the ring stops growing,
TOD-bounded) is the more principled variant and a candidate refinement — it
would be backend-agnostic in cost, but needs care around CIA1 TOD latch
interaction with the UCI adapter's own TOD-based waits.
Correctness is unaffected either way — every hardware and VICE run passes; this
is purely wall-clock.
Activity
tools/uci: skip redundant turbo write — unblocks C64U 64 MHz measurement
docs: refresh benchmarks + ip65 status for #68/#69/#71/#74 (#76)
docs: switching BACKEND without `make clean` silently links a mixed PRG