code wiki / (root) / nx_galx_vidoff.nx

nx_galx_vidoff.nx

buildroot/runtime/nx_galx_vidoff.nx

2876 B48 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

about

nx_galx_vidoff.nx -- SOVEREIGN O(1) line-offset index for galx_vid_paths.tsv. The gallery daemon maps daemon-id -> .ts path on EVERY /vid/<id>/* request (poster, init, segs, seg). Doing that by reading the whole 4.35MB / 62k-line TSV costs ~16ms PER REQUEST (slow /mnt/c 9p) -> it dominates grid-poster load and seek latency. This builds a compact sidecar so the daemon can seek straight to line <id>: read 8 bytes at id*8, lseek the TSV, read one line. Two tiny reads, not 4.35MB. Format (big-endian): tsv_size(8) n(8) then n * off(8) -- off[id] = byte offset of line <id>'s start. tsv_size is the TSV size at build time = the daemon's freshness check (size changed -> rebuild/fallback). id is 0-indexed to match gs_vid_line. Idempotent: just rebuild whenever the TSV changes. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_galx_vidoff.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_clock_now_us sys_now_us sys_mmap sys_clock_gettime_mono sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close pe sys_write w64be sys_openat_wr sys_write ↻ sys_close ↻ pn sys_mmap ↻ sys_write ↻

structs

none

consts

none

functions

12func w64be(b: *u8, o: i64, v: i64) -> i64
called by 1: main
17func pe(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return sys_write(2,s,n) }
called by 1: main calls 1: sys_write
18func pn(v: i64) -> i64 { var m: i64=v; if m<0{m=0-m} let b: *u8=sys_mmap(32); var i: i64=32; if m==0{i=i-1;b[i]=(48 as u8)} while m>0{let q: i64=m/10; i=i-1; b[i]=((48+(m-q*10)) as u8); m=q} return sys_write(2,((b as i64)+i) as *u8,32-i) }
called by 1: main calls 2: sys_mmapsys_write
20func main(argc: i64, argv: *i64) -> i64