From 895aa43ab90c49d77bd5c72b05412f2cb13ceb2e Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Tue, 27 Oct 2026 00:56:48 +0300 Subject: [PATCH] Wake the completion thread for a new callback only when its value is already reached: the replay's callbacks wait for the submission it records, whose submit wakes the thread anyway Co-Authored-By: Claude Opus 5.5 --- runtime/vk_sync.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/vk_sync.c b/runtime/vk_sync.c index fbbf465e..d65a4976 100644 --- a/runtime/vk_sync.c +++ b/runtime/vk_sync.c @@ -381,7 +381,9 @@ void vk_completion_add(uint64_t fence, void (*fn)(void *), void *arg) { } } queue[qhead + qn++] = (Pending){fence, fn, arg}; - WakeAllConditionVariable(&cv_work); + // The completion thread sleeps only while nothing is issued beyond done: a callback for a later value (the replay's, + // for the submission it records: counter reports, freed resources) becomes due through the submit, which wakes it. + if (fence <= done) WakeAllConditionVariable(&cv_work); ReleaseSRWLockExclusive(&st_lock); }