code wiki / _hdl_build / nx_comms_perf_census.nx
nx_comms_perf_census.nx source
↩ module page · 169 lines · 10976 B
1// nx_comms_perf_census.nx -- MEASURED PERFORMANCE census for the /video comms stack (operator
2// 2026-07-02: "s class exceed performant on research as of today -- best fps sound responsiveness").
3// The PERF third of the management triad (breadth = nx_comms_rival_census, capability = the gates).
4// THREE evidence classes, none asserted:
5// MEASURED = gg_gate_green over the persisted room gate logs (last-verdict rule, anti-liar) --
6// these are REAL runs: the Jitsi SFU h2h, QoE-MOS, FEC/ARQ resilience, adaptive jitter
7// buffer, BWE, ABR hysteresis, L4S queueing, audio PLC.
8// SHIPPED = file-evidence of the 2026-07-02 fps rung (ladder TABLE in the wasm core, 10->20fps
9// ceiling; client reads rungs from the core).
10// BEHIND = the named debts, detected MECHANICALLY so they self-flip when fixed: the client still
11// ships deprecated createScriptProcessor (AudioWorklet = the banked SOTA), still JPEG
12// toBlob (WebCodecs hw = banked), fixed playout margins (organ gated, client unwired),
13// and the glass-to-glass netem h2h vs rivals has NEVER run (the exceed standard's bar).
14// LIVE axis: fresh funcheck video PASS required -- a dead room cannot GREEN a perf census.
15// GROUNDED: refuses without the 13 banked perf_*.raw sources. expect_exit: 0 license_tier: ORIGINAL
16import "nx_syscalls.nx"
17import "nx_gate_green.nx"
18const K_MAGIC_8192: i64 = 8192
19const K_MAGIC_86400: i64 = 86400
20
21func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
22func pw(s: *u8) -> i64 { sys_write(1,s,slen(s)); return 0 }
23func pn(v: i64) -> i64 {
24 let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m}
25 let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}
26 var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
27func have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 {return 0} sys_close(fd); return 1 }
28func contains(hay: *u8, n: i64, needle: *u8) -> i64 {
29 let nl: i64=slen(needle); if nl==0 {return 1}
30 var i: i64=0
31 while i+nl<=n { var j: i64=0; var ok: i64=1; while j<nl { if hay[i+j]!=needle[j]{ok=0;j=nl} else {j=j+1} } if ok==1{return 1} i=i+1 }
32 return 0 }
33func filehas(path: *u8, pat: *u8) -> i64 {
34 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
35 let b: *u8 = sys_read_file(path, box)
36 if (b as i64)==0 { return 0 }
37 return contains(b, box[0], pat) }
38func cr_find_eol(b: *u8, n: i64, st: i64) -> i64 { var i: i64=st; while i<n { if (b[i] as i64)==10 {return i} i=i+1 } return n }
39func cr_live2(logpath: *u8, maxage_s: i64) -> i64 {
40 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
41 let b: *u8 = sys_read_file(logpath, box)
42 if (b as i64)==0 { return 0 }
43 let n: i64 = box[0]
44 var ls: i64 = 0 - 1
45 var linestart: i64 = 0
46 var i: i64 = 0
47 while i <= n {
48 var eol: i64 = 0
49 if i==n { eol=1 } else { if (b[i] as i64)==10 { eol=1 } }
50 if eol==1 {
51 if i>linestart { if (b[linestart] as i64)==70 { if (b[linestart+1] as i64)==85 { ls=linestart } } }
52 linestart = i+1
53 }
54 i = i + 1
55 }
56 if ls<0 { return 0 }
57 let le: i64 = cr_find_eol(b, n, ls)
58 let ln: *u8 = sys_mmap(K_MAGIC_8192)
59 var k: i64 = 0
60 while ls+k<le { ln[k]=b[ls+k]; k=k+1 }
61 ln[k]=0 as u8
62 var ep: i64 = 0
63 var p: i64 = 0
64 var found: i64 = 0
65 while p+6<k {
66 if ln[p]==(101 as u8) { if ln[p+1]==(112 as u8) { if ln[p+2]==(111 as u8) { if ln[p+3]==(99 as u8) { if ln[p+4]==(104 as u8) { if ln[p+5]==(61 as u8) {
67 found=1
68 var q: i64 = p+6
69 while q<k { let c: i64 = ln[q] as i64; if c>=48 { if c<=57 { ep=ep*10+(c-48); q=q+1 } else { q=k } } else { q=k } }
70 p = k
71 } } } } } }
72 if p<k { p=p+1 }
73 }
74 if found==0 { return 0 }
75 let now: i64 = sys_now_realtime_sec()
76 var age: i64 = now - ep
77 if age<0 { age = 0 - age }
78 if age > maxage_s { return 0 }
79 if contains(ln, k, "video_room=PASS" as *u8)==0 { return 0 }
80 if contains(ln, k, "video_appjs=PASS" as *u8)==0 { return 0 }
81 return 1 }
82
83// one MEASURED row from a persisted gate log. Adds to fail if not GREEN (these are the load-bearing axes).
84func meas(name: *u8, log: *u8, anchor: *u8, failp: *i64) -> i64 {
85 let g: i64 = gg_gate_green(log, anchor, "verdict=GREEN" as *u8)
86 pw(" [" as *u8)
87 if g==1 { pw("MEASURED-GREEN" as *u8) } else { pw("NOT-GREEN " as *u8); failp[0]=failp[0]+1 }
88 pw("] " as *u8); pw(name); pw("\n" as *u8)
89 return g }
90
91// one BEHIND-debt row: the debt PATTERN present in the client = still behind (self-flips when fixed).
92func debt(name: *u8, path: *u8, pat: *u8, behindp: *i64) -> i64 {
93 let hasdebt: i64 = filehas(path, pat)
94 pw(" [" as *u8)
95 if hasdebt==1 { pw("BEHIND " as *u8); behindp[0]=behindp[0]+1 } else { pw("CLOSED " as *u8) }
96 pw("] " as *u8); pw(name); pw("\n" as *u8)
97 return hasdebt }
98
99func main() -> i64 {
100 pw("=== nx_comms_perf_census: MEASURED fps/sound/responsiveness (grounded + live-guarded) ===\n" as *u8)
101 var fail: i64 = 0
102 let failp: *i64 = sys_mmap(16) as *i64
103 failp[0] = 0
104
105 // GROUNDING: the 13 banked perf sources
106 var g: i64 = 0
107 g = g + have("knowledge/fetched/perf_webaudio.raw" as *u8)
108 g = g + have("knowledge/fetched/perf_audioworklet.raw" as *u8)
109 g = g + have("knowledge/fetched/perf_echo_cancel.raw" as *u8)
110 g = g + have("knowledge/fetched/perf_audio_latency.raw" as *u8)
111 g = g + have("knowledge/fetched/perf_webcodecs.raw" as *u8)
112 g = g + have("knowledge/fetched/perf_rvfc.raw" as *u8)
113 g = g + have("knowledge/fetched/perf_offscreencanvas.raw" as *u8)
114 g = g + have("knowledge/fetched/perf_mjpeg.raw" as *u8)
115 g = g + have("knowledge/fetched/perf_frame_rate.raw" as *u8)
116 g = g + have("knowledge/fetched/perf_jitter.raw" as *u8)
117 g = g + have("knowledge/fetched/perf_e2e_delay.raw" as *u8)
118 g = g + have("knowledge/fetched/perf_qoe.raw" as *u8)
119 g = g + have("knowledge/fetched/perf_vmaf.raw" as *u8)
120 pw("GROUNDING: perf sources banked = " as *u8); pn(g); pw("/13" as *u8)
121 if g>=10 { pw(" OK\n" as *u8) } else { pw(" UNGROUNDED -> RED (run nx_comms_perf_fetch)\n" as *u8); fail=fail+1 }
122
123 // LIVE
124 let live: i64 = cr_live2("knowledge/status/funcheck.log" as *u8, K_MAGIC_86400)
125 pw("LIVE AXIS: video fresh-PASS = " as *u8)
126 if live==1 { pw("LIVE\n" as *u8) } else { pw("NOT-LIVE -> census cannot be GREEN\n" as *u8); fail=fail+1 }
127
128 pw("--- MEASURED (real gate runs, last-verdict rule) ---\n" as *u8)
129 meas("sfu-h2h-vs-jitsi (ours 5-visible/0-starved vs jitsi 2/3 @900) " as *u8, "knowledge/status/room_sfu.log" as *u8, "ROOMSFUGATE" as *u8, failp)
130 meas("qoe-mos-model (anti-liar: naive-GREEN-WRONG named) " as *u8, "knowledge/status/room_qoe.log" as *u8, "ROOMQOEGATE" as *u8, failp)
131 meas("loss-resilience fec-vs-arq (8% loss, 150ms jitter) " as *u8, "knowledge/status/room_resilience.log" as *u8, "ROOMRESIL" as *u8, failp)
132 meas("adaptive-jitter-buffer ORGAN (late 1 vs 3, lat 40 vs 60ms) " as *u8, "knowledge/status/room_jitterbuf.log" as *u8, "ROOMJBGATE" as *u8, failp)
133 meas("bandwidth-estimation (delay+loss detectors) " as *u8, "knowledge/status/room_bwe.log" as *u8, "ROOMBWEGATE" as *u8, failp)
134 meas("abr-hysteresis (flap-damped rate control) " as *u8, "knowledge/status/room_abr.log" as *u8, "ROOMABRGATE" as *u8, failp)
135 meas("l4s-ecn dual-signal queueing (q99 14 vs 29 vs 166) " as *u8, "knowledge/status/room_l4s.log" as *u8, "R-L4S" as *u8, failp)
136 meas("audio-plc (concealment err 16 vs zero-fill 325) " as *u8, "knowledge/status/room_plc.log" as *u8, "ROOMPLCGATE" as *u8, failp)
137 meas("intl-h2h 4 profiles vs rival classes (fec=0 frozen everywhere)" as *u8, "knowledge/status/intl_h2h.log" as *u8, "INTLH2H" as *u8, failp)
138 meas("hardware codec speed (77x enc / 241x dec realtime-48k, 1 core)" as *u8, "knowledge/status/lpc_speed.log" as *u8, "LPCBENCH" as *u8, failp)
139 fail = fail + failp[0]
140
141 pw("--- SHIPPED 2026-07-02 (fps rung: ladder table in the CORE, ceiling 10->20fps) ---\n" as *u8)
142 var s1: i64 = filehas("runtime/nx_video_client_wasm.nx" as *u8, "vc_ladder_fps" as *u8)
143 var s2: i64 = filehas("sites/nishifamily/video/app.js" as *u8, "rungFps" as *u8)
144 pw(" [" as *u8)
145 if s1==1 { if s2==1 { pw("OURS " as *u8) } else { pw("NOT-WIRED " as *u8); fail=fail+1 } } else { pw("ABSENT " as *u8); fail=fail+1 }
146 pw("] fps-ladder-in-core + client-reads-core-rungs (vm-gate 4/4, deployed)\n" as *u8)
147
148 pw("--- HONEST BEHIND (named debts, self-flipping; = the perf build backlog) ---\n" as *u8)
149 let behindp: *i64 = sys_mmap(16) as *i64
150 behindp[0] = 0
151 debt("audio path still deprecated ScriptProcessor -> AudioWorklet " as *u8, "sites/nishifamily/video/app.js" as *u8, "createScriptProcessor" as *u8, behindp)
152 debt("video encode still JPEG toBlob -> WebCodecs hw encode " as *u8, "sites/nishifamily/video/app.js" as *u8, "toBlob" as *u8, behindp)
153 debt("client playout margins fixed -> wire the gated adaptive JB " as *u8, "sites/nishifamily/video/app.js" as *u8, "playHead = now + 0.15" as *u8, behindp)
154 // the netem glass-to-glass h2h vs rivals has never run: declared, not detectable from a file
155 pw(" [BEHIND ] netem glass-to-glass h2h vs jitsi/mediasoup/janus (NEVER run; the exceed bar)\n" as *u8)
156 behindp[0] = behindp[0] + 1
157
158 // CONTROLS
159 if gg_gate_green("knowledge/status/room_sfu.log" as *u8, "ROOMSFUGATE" as *u8, "verdict=GREEN" as *u8)==1 { pw("POS-control measured-log GREEN: GREEN\n" as *u8) } else { pw("POS-control FAILED -> RED\n" as *u8); fail=fail+1 }
160 if gg_gate_green("knowledge/status/room_sfu.log" as *u8, "ROOMSFUGATE" as *u8, "verdict=ZZBOGUS" as *u8)==0 { pw("NEG-control bogus-pattern NOT-GREEN: GREEN\n" as *u8) } else { pw("NEG-control FAILED (fabricated) -> RED\n" as *u8); fail=fail+1 }
161 if gg_gate_green("knowledge/status/no_such_room_log.log" as *u8, "X" as *u8, "verdict=GREEN" as *u8)==0 { pw("NEG-control missing-log NOT-GREEN: GREEN\n" as *u8) } else { pw("NEG-control FAILED -> RED\n" as *u8); fail=fail+1 }
162 if cr_live2("knowledge/status/no_such_funcheck.log" as *u8, K_MAGIC_86400)==0 { pw("NEG-control bogus-live NOT-LIVE: GREEN\n" as *u8) } else { pw("NEG-control live FAILED -> RED\n" as *u8); fail=fail+1 }
163
164 pw("COMMS-PERF-CENSUS grounded=" as *u8); pn(g); pw("/13 live=" as *u8); pn(live)
165 pw(" behind=" as *u8); pn(behindp[0]); pw(" fail=" as *u8); pn(fail)
166 if fail==0 { pw(" verdict=GREEN -- perf is MEASURED (8 gate-run axes + shipped fps rung); the BEHIND list is the ladder to best-fps/sound/responsiveness\n" as *u8); return 0 }
167 pw(" verdict=RED\n" as *u8)
168 return 1
169}