Linux EEVDF 排程:為什麼低延遲不等於永遠優先 / Linux EEVDF Scheduling: Why Low Latency Does Not Mean Always First 現象: 同一台 Linux 主機上,終端機輸入偶爾卡頓,AI 推論或編譯工作卻沒有停止。很多人第一個反應是把互動程式設成「最高優先權」,但這可能只是把延遲轉移給別的工作。Linux 近年的公平排程路徑使用 EEVDF(Earliest Eligible Virtual Deadline First)整理可執行工作:它不是承諾某個程式永遠先跑,而是在公平性與回應時間之間計算下一個選擇。 Symptom: On the same Linux host, terminal input can feel sticky while an AI inference or build continues to run. The first reaction is often to give the interactive task the highest priority, but that may only move the latency elsewhere. Recent Linux fair-scheduling work uses EEVDF, or Earliest Eligible Virtual Deadline First, to order runnable tasks. It does not promise that one program always runs first; it computes a next choice between fairness and responsiveness. 圖一|EEVDF 先判斷工作是否 eligible,再比較虛擬截止時間。 / Figure 1 | EEVDF checks eligibility before comparing virtual deadlines. 機制:先理解 eligible,再談 deadline / Mechanism: Eligibility Comes Before the Deadline 公平排程器不只看「誰等最久」。每個工作會在虛擬執行時間軸上累積進度,並依...
Android 端側 AI 為什麼要在 DMA-BUF 停一下?零拷貝不等於零同步 / Android On-Device AI: DMA-BUF Zero-Copy Still Needs Synchronization
daily-tech:2026-11-20 現象:模型沒有變大,畫面卻開始卡 / Symptom: The model is unchanged, but frames stall 手機把相機畫面交給端側 AI 模型時,最直覺的做法是先複製到 CPU,再複製到 GPU 或 NPU。資料量一大,模型本身可能沒有變慢,真正增加的是搬運、等待與格式轉換。共享 buffer 可以減少複製,但若忽略同步,畫面可能讀到未完成的資料,或因等待 producer 而出現尾端延遲。 When a phone sends camera frames to an on-device AI model, the obvious path copies pixels through the CPU and then to the GPU or NPU. With larger frames, transport, waiting, and format conversion can dominate even when the model is unchanged. Shared buffers can reduce copies, but missing synchronization can expose incomplete data or create tail latency. Android AI buffer path Camera / CPU producer AHardwareBuffer shared handle DMA-BUF fd import + fence GPU / NPU consumer cache sync + fence + lifetime still matter 圖 1|共享 buffer 減少搬運,但 cache、fence 與生命週期仍需管理。 / Figure 1 | Shared buffers reduce copies, but cache, fences, and lifetime still need explicit management. 機制:HardwareBuffer 是入口,DMA-BUF 是共享路徑 / Mechanism: HardwareBuffer is the Android entry, DMA-BUF i...