Expand description
Client diet (PLAN-phase4 §4): the allocator knobs and purge points that make the thin client’s RssAnon equal its live heap instead of its high-water mark.
-
tune_allocator()— called frommain()on the attach path before the runtime or any thread exists: jemalloc background threads off (so none are spawned for the arenas the render/crossterm threads touch; 8 → 4 threads),dirty_decay_ms=0/muzzy_decay_ms=0(a freed run goes back to the OS on the next decay tick instead of ≤ 10 s later). -
purge_arenas(stage)— explicitarena.<all>.purge+ a ladder line. -
IdlePurge— therun_looparm: purge N s after the client goes idle (turn/compaction finished), plus the syntect idle-eviction hook. -
PR_SET_THP_DISABLEfirst: withTHP=always(bella, most desktops) every touched thread stack, the.bssand each arena chunk is a 2 MiB page — the A1 ladder showed +4 MB atrender_threadfor 128 KB of allocations.SYNAPS_CLIENT_THP=1keeps huge pages.
Flags: SYNAPS_CLIENT_MALLOC=off / SYNAPS_CLIENT_ALLOC=default skip the
mallctls; SYNAPS_CLIENT_TCACHE=0 disables the main thread’s tcache;
SYNAPS_CLIENT_PURGE_SECS / SYNAPS_CLIENT_PURGE_IDLE_SECS (default 10,
0 = never); SYNAPS_MEMPROF_PURGE=1 purges on every idle immediately.
Structs§
- Idle
Purge - The
run_loopidle arm’s state machine. Busy = streaming or compacting. On the busy→idle edge the first fire is scheduleddelaylater (ladderidle+N→ purge →purged); afterwards every [IDLE_TICK] while still idle (syntect eviction + a silent purge). Purging is Socket-only; the eviction check runs in both modes (same code, same render output).
Functions§
- allocator_
tuning_ disabled - Mallctls skipped? (
SYNAPS_CLIENT_MALLOC=offorSYNAPS_CLIENT_ALLOC=default). - purge_
arenas arena.<all>.purgeand one ladder line atstage.- purge_
delay - Idle purge delay:
SYNAPS_CLIENT_PURGE_SECS(aliasSYNAPS_CLIENT_PURGE_IDLE_SECS), default 10;None= disabled (0).SYNAPS_MEMPROF_PURGE=1→ immediate. - tune_
allocator - §4.1–4.3 in order, each result recorded on the
allocladder line; never fatal (risk #9). Must run before any thread is spawned.