code wiki / _hdl_build / nx_ctxtop.nx
nx_ctxtop.nx
buildroot/runtime/_hdl_build/nx_ctxtop.nx
about
nx_ctxtop.nx -- WHO is producing the context switches. The producer-finder for seq1340.
nx_procchurn measured the box at 81k-93k ctxsw/sec in every sample (the one CONSTANT in the perf lane)
and DISPROVED forks as the driver -- forks swing 15->179->10 while ctxsw stays flat. A box-level rate
names no culprit, so this walks /proc/<pid>/status twice and attributes the switches per process.
LAW (rising-debt-means-find-the-producer): a rate with no owner is a symptom, not a diagnosis.
★Reports voluntary and nonvoluntary SEPARATELY because they demand OPPOSITE fixes: voluntary = the
process blocked itself (poll/read/sleep) -> batch, lengthen polls, go event-driven; nonvoluntary = the
scheduler preempted it -> reduce concurrency. A tool printing only the sum sends the fix the wrong way.
Exit code = 0 when the sample completed, 3 UNMEASURED (fail-closed, never a confident empty answer).
license_tier: ORIGINAL Read-only. No hw writes (Rule 26). expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_ctxtop_lib.nxnx_proc_ctl.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
| 16 | const CT_MAXP: i64 = 2048 |
| 17 | const CT_TABLE_BYTES: i64 = 16384 |
| 18 | const CT_DIRBUF: i64 = 65536 |
| 19 | const CT_STATBUF: i64 = 4096 |
| 20 | const CT_TOPK: i64 = 8 |
| 21 | const CT_TOPK_BYTES: i64 = 128 |
| 22 | const CT_WINDOW_MS: i64 = 3000 |
| 23 | const CT_US_PER_MS: i64 = 1000 |
| 24 | const CT_NAMEOFF: i64 = 6 |
| 25 | const CT_EXIT_UNMEASURED: i64 = 3 |
| 26 | const CT_SLASH: i64 = 47 |
| 27 | const CT_EXIT_REFUSED: i64 = 4 |
| 28 | const CT_ADMIT_DEFAULT: i64 = 800 |
| 29 | const CT_CONFBUF: i64 = 4096 |
| 30 | const CT_LOADBUF: i64 = 128 |
functions
| 34 | func ct_scan(pids: *i64, vols: *i64, nvs: *i64, dbuf: *u8, path: *u8, sbuf: *u8) -> i64 |
| 128 | func ct_putname(pid: i64, path: *u8, sbuf: *u8) -> i64 |
| 150 | func main() -> i64 |