現象:io_uring 非同步,為什麼服務仍會卡住? / Symptom: Why can an io_uring service still stall? 你把大量檔案讀取改成 Linux io_uring,CPU 使用率下降,卻仍看到請求延遲突然拉高。提交請求變得非同步,不代表儲存裝置立刻完成;queue depth、檔案系統與 block I/O 仍會把等待時間留在 completion 之前。 You moved file reads to Linux io_uring, CPU usage fell, yet request latency still spikes. Submission becomes asynchronous; storage, the filesystem, and block I/O can still delay completion. io_uring 的基本路徑是:應用程式準備 submission queue entry(SQE),核心取出並執行,最後把結果寫成 completion queue entry(CQE)。共享 ring 減少系統呼叫,但 CQE 的 res 才是實際結果;不能只看到 SQE 已提交,就把工作算成完成。 The path is: the application prepares an SQE, the kernel executes it, and a CQE reports the result. Shared rings reduce syscall traffic, but CQE res is the real outcome. Submission is not completion. 圖一|io_uring 的 SQE→核心執行→CQE 路徑;固定 buffer 的生命週期與完成延遲必須分開觀察。 / Figure 1 | The SQE-to-kernel-to-CQE path; buffer lifetime and completion latency are separate signals. Original conceptual diagram. 機制:固定 Buffer 解決什麼,又帶來什麼責任? / Mechanism: what registered bu...
Linux 為什麼還沒 OOM 就開始卡頓?用 PSI 讀懂 CPU、記憶體與 I/O 壓力 / Before OOM: Reading Linux Pressure Stall Information
現象:為什麼還沒 OOM 就開始卡? / Symptom: Why does Linux stall before OOM? 你是否遇過這種情況:記憶體還有剩、CPU 也沒有 100%,但 SSH 變慢、服務延遲突然拉高,甚至工作負載尚未被 OOM Killer 終止就已經「像死機」?這不是單看使用率就能回答的問題。Linux Pressure Stall Information(PSI)量的是工作真的因資源不足而等待了多久,讓「還能跑」與「已經在浪費時間」分開。 Have you seen a Linux host become sluggish while memory is still available and CPU is below 100%? PSI addresses the missing signal: not how full a resource looks, but how long runnable work is actually delayed by contention. A machine can be operational and already wasting latency before the OOM killer appears. PSI 的核心不是額外的效能計數器,而是把資源競爭轉成「停滯時間」。核心分別在 /proc/pressure/cpu、memory、io 匯出資料;some 表示至少一部分工作正在等待,full 則表示所有非閒置工作同時卡住。memory full 或 io full 長時間上升,比單獨看到 free 變少更接近「系統正在失去生產力」的現象。 PSI turns contention into stall time. The kernel exports cpu, memory, and io pressure files under /proc/pressure. “some” means at least some work is stalled; “full” means all non-idle work is stalled at once. A sustained memory-full or io-full signal is often more actionable tha...