從 DMA-BUF 到 AHardwareBuffer:拆解 Android 與 Linux 端側 AI 零拷貝管線 / From DMA-BUF to AHardwareBuffer: Deconstructing Zero-Copy Pipelines in Android and Linux Edge AI
daily-tech:2026-11-25 從 DMA-BUF 到 AHardwareBuffer:拆解 Android 與 Linux 端側 AI 零拷貝管線 / From DMA-BUF to AHardwareBuffer: Deconstructing Zero-Copy Pipelines in Android and Linux Edge AI 現象: 在智慧型手機或邊緣嵌入式裝置上執行即時影像 AI(例如物件偵測、語意分割或姿態辨識)時,許多團隊常遇到一種難堪的效能瓶頸:明明選用了輕量化的量化神經網路,推論核心花費的時間僅需 15 毫秒,然而整體管線的端到端延遲卻高達 45 毫秒以上,甚至伴隨著 CPU 使用率飆高與手機發燙。深入分析效能剖析數據後會發現,推論本身很快,耗時全卡在「相機取像後把點陣圖複製給 GPU 前處理」、「GPU 處理完再拷貝成張量陣列交給 NPU」這兩次不必要的記憶體搬移上。 Symptom: When deploying real-time vision AI (such as object detection, semantic segmentation, or pose estimation) on smartphones or edge embedded devices, engineering teams often face an unexpected performance bottleneck: despite choosing an ultra-lightweight quantized neural network whose core inference takes only 15 milliseconds, the end-to-end pipeline latency exceeds 45 milliseconds, accompanied by soaring CPU utilization and device throttling. Profiling reveals that raw inference is swift; the real culprits are redundant memory copies between camera ISP buffers, GPU preproces...