From edee0d6bc6ff8b0ed5355dbf171648b2122fd549 Mon Sep 17 00:00:00 2001 From: Nikhil Jain Date: Thu, 29 Jan 2026 20:55:38 -0800 Subject: [PATCH] Add comment --- ggml/src/ggml-webgpu/ggml-webgpu.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-webgpu/ggml-webgpu.cpp b/ggml/src/ggml-webgpu/ggml-webgpu.cpp index 7f2f9ecc4d..d1723ff73f 100644 --- a/ggml/src/ggml-webgpu/ggml-webgpu.cpp +++ b/ggml/src/ggml-webgpu/ggml-webgpu.cpp @@ -146,8 +146,13 @@ struct webgpu_submission_futures { struct webgpu_buf_pool { std::vector free; + // The pool must be synchronized because: + // 1. The memset pool is shared globally by every ggml buffer, + // since allocating a pool per ggml buffer would consume too much memory. + // 2. For the per-thread buffer pools in webgpu_context, + // buffers are allocated and freed in Dawn callbacks, + // which can run on a different thread than the calling thread. std::mutex mutex; - std::condition_variable cv; void init(wgpu::Device device,