From d05eb9740889429d3935c64cde78d3e843149a1a Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sat, 16 Mar 2024 20:15:47 -0700 Subject: [PATCH] venus: further reduce idle timeout from 5ms to 1ms Similar to the rationale for the 50ms -> 5ms adjustment before. When there's enough cpu cycles, doing so would only help reduce cpu utilization. When cpu is mostly drained, less host side unnecessary polling is favored by the scheduler. Also in the latter case, it'd be the non-primary ring, so it doesn't hurt to idle out faster. Besides the theory, there's no regression in popular benchmarks, but only power wins. Making the idle timeout too small will lead to overhead built up. e.g. From the initial notify to ring being waken up, it's about 200us. The notify op is more expensive than ring thread doing a few more polls. However, we normally would save many more polls by idle out earlier. From my local testing, reducing down to 500us won't incur and real perf regressions either. Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/virtio/vulkan/vn_ring.c b/src/virtio/vulkan/vn_ring.c index e880853951c..6e97480f252 100644 --- a/src/virtio/vulkan/vn_ring.c +++ b/src/virtio/vulkan/vn_ring.c @@ -11,7 +11,7 @@ #include "vn_instance.h" #include "vn_renderer.h" -#define VN_RING_IDLE_TIMEOUT_NS (5ull * 1000 * 1000) +#define VN_RING_IDLE_TIMEOUT_NS (1ull * 1000 * 1000) static_assert(ATOMIC_INT_LOCK_FREE == 2 && sizeof(atomic_uint) == 4, "vn_ring_shared requires lock-free 32-bit atomic_uint");