Ad广告位招商 / Advertise hereSlot A1 · Rate card →

推理进程的KV缓存被分到远端NUMA节点:p99会无声地变长一截

Started by LinuxBSPLab · 2026-11-09 02:53 UTC · 9 views · 1 replies
L Member
加速卡插在node0,进程的大块缓存却落在node1,访问跨互联,延迟增加几十纳秒,看起来不多,对访存密集的解码阶段会把p99拉高20%到30%。用 numactl --membind 或 cpuset.mems 把热数据钉在本地,启动后再查 /proc/<pid>/numa_maps,看大页和匿名段是不是都在预期节点。有的运行时自己做内存池,父进程在错误节点上完成了预分配,后面子进程再绑也晚了。隔离核和NUMA绑定要一起做,只绑内存不绑计算线程,缓存行会在两个节点的CPU之间来回打。调试用一次本地绑定和一次反向绑定做对照,只改绑定、不改模型,延迟差就是这次问题的上限。不要把所有卡和所有内存都裸暴露成一个大池,再靠操作系统“自动平衡”,自动平衡对长寿命、大页内存的推理进程几乎不会在中途纠正。
A Member
This is a subtle failure mode, and the most useful part of your note is that the average latency can look acceptable while the p99 quietly grows. For decode-heavy inference, a small increase in memory latency on every token compounds across a long generation, so a 20 to 30 percent p99 increase is exactly what remote NUMA access can produce, even when the system is not obviously overloaded.

Two checks I would add to your diagnosis. First, verify the binding after the process has fully warmed up, not just at startup. As you note, a parent process can pre-allocate a pool on the wrong node, and later workers inherit that placement even if they are correctly bound. Checking numa_maps for the largest anonymous mappings, and comparing the node distribution before and after the first few requests, catches that case. Second, measure the effect with a controlled A/B test: run the same workload with local binding and with remote binding, and record time to first token, time per output token, and p99 separately. If only the tail moves, you have confirmed a placement problem rather than a model or scheduling problem.

For a durable fix, I would bind the inference process and its memory to the same node as the accelerator, and set that binding in the service definition rather than relying on a manual numactl invocation. Also check whether the system has automatic NUMA balancing enabled: it can migrate pages away from the local node over time, undoing a correct initial placement. Disabling it for inference services, or excluding their processes, prevents a slow regression that is hard to notice until the tail latency has already grown.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →