code wiki / _hdl_build / nx_kaprobe.nx
nx_kaprobe.nx
buildroot/runtime/_hdl_build/nx_kaprobe.nx
about
nx_kaprobe.nx -- HTTP/1.1 KEEP-ALIVE CONNECTION REUSE probe + capability proof (census gap #3:
"connection reuse ABSENT: Connection: close ... SOTA keep-alive = 50-80% latency cut for multi-page hosts").
The proven TLS send/recv core (nx_https_req_complete) ALREADY leaves the session CONNECTED after a
Content-Length response (cl-stop) with the app-data seq counters advanced -- so a SECOND request over the
SAME session/fd just works. The only thing forcing teardown was the request builder's "Connection: close".
This organ builds a "Connection: keep-alive" request and measures TWO batches of K GETs to the sovereign
edge (loopback 127.0.0.1:8443), both with a WARM cert cache (fair vs the current cache-only production):
BATCH A (reuse): 1 handshake + K GETs over ONE session.
BATCH B (no-reuse): K (handshake + GET + close) cycles = today's close-per-request behavior.
saving = B - A = ~(K-1) handshakes avoided. Emits netobs_keepalive_batch_ms / _noreuse_batch_ms /
_saved_ms / _per_req_ms so /netobs tracks the reuse win as a continuous series. Self-diagnosing: if the
server does not honor keep-alive (request 2 fails on a torn session) the probe reports VERDICT=RED honestly.
Rule 26: read-only network probe, zero hardware writes. Envelope: K=5 GETs/batch, loopback-only, 8s tmo.
license_tier: ORIGINAL expect_exit: 0
dependencies 12 imports · 0 importers
diagram shows first 10 each side; +2 more imports, +0 more importers in the complete lists below.
imports: nx_sovjson_lib.nxnx_itoa_lib.nxnx_connect.nxnx_syscalls.nxnx_csprng.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_tls13_client_validate_certificate.nxnx_tls13_client_session_run.nxnx_tls13_client_session.nxnx_https_get_complete.nxnx_tls_cert_cache.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 27 | const KA_MAGIC_8443: i64 = 8443 |
| 28 | const KA_MAGIC_4194304: i64 = 4194304 |
| 29 | const KA_MAGIC_1024: i64 = 1024 |
| 30 | const KA_MAGIC_4096: i64 = 4096 |
| 32 | const KA_CERTDATA: *u8 = "data/mozilla_certdata.txt" as *u8 |
| 33 | const KA_CERT_CAP: i64 = 16384 |
| 34 | const KA_OUTCAP: i64 = 262144 |
| 35 | const KA_LEDGER: *u8 = "knowledge/status/netobs_metrics.log" |
| 36 | const KA_K: i64 = 5 |
functions
| 38 | func ka_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 43 | func ka_wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 44 | func ka_cat(d: *u8, o: i64, s: *u8) -> i64 { return sj_cat(d, o, s) } |
| 45 | func ka_catn(d: *u8, o: i64, v: i64) -> i64 { return sj_catn(d, o, v) } |
| 46 | func ka_mrow(lb: *u8, o: i64, name: *u8, ts: i64, val: i64) -> i64 |
| 58 | func ka_append(buf: *u8, n: i64) -> i64 |
| 68 | func ka_build_request(out: *u8, path: *u8, host: *u8) -> i64 |
| 77 | func ka_connect() -> i64 |
| 96 | func ka_handshake(store: *TrustStore, host: *u8, hlen: i64, now: i64, fd: i64) -> i64 |
| 113 | func main(argc: i64, argv: *i64) -> i64 |