mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 23:59:59 -04:00
Let the completion thread's collect give way while an upload holds the upload lock.
completion_main calls vk_mem_collect after it publishes each new done, and vk_mem_collect waited for cmd_lock. An upload flush holds that lock across vk_queue_lock, behind a present call (FIFO, a frame limiter inside the present, frame generation) or another long queue-lock hold. With wait = 1 it also holds it across its batches' fence waits, and stg_create waits for batch fences under it. The single completion thread blocked there could not process the next timeline value, so the next done, and every fence waiter for it, waited for that chain. vk_mem_collect_try only tries cmd_lock. When the lock is busy it still destroys the finalized pools, which need only retire_lock, and leaves the deferred objects to a later completion or to the next upload flush's own collect. After eight busy tries in a row it waits as vk_mem_collect does, which keeps the deferred list bounded, as before. pool_fini keeps the waiting vk_mem_collect. The trace=perf "mem: sizes" GPU line counts the collects that gave way. Not reproduced before the change: the completion thread's lock waits are not timed. Checks that passed: pass_cc_check on every runtime file (vk.h changed), no new -Wall -Wextra warnings in vk_memory.c and vk_sync.c, sync_hw_check, gpa_check, mem_budget_check, tex_release_check, mem_growth_check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1052,7 +1052,8 @@ static void completion_main(void *arg) {
|
||||
// The waiters go first (a fence wait, the frame's first submission, the acquire): freeing what the
|
||||
// finished submissions held (vk_mem_collect: upload batches, destroyed images, views and buffers, each
|
||||
// checked against the timeline itself) is nothing they read, and it takes cmd_lock, which the upload
|
||||
// path holds, so done waited behind uploads.
|
||||
// path holds, so done waited behind uploads. It only tries that lock (vk_mem_collect_try): an upload flush
|
||||
// can hold it while it waits behind a present for the queue lock, and the next value's done waited too.
|
||||
uint64_t tv = __atomic_load_n(&tail_val, __ATOMIC_ACQUIRE);
|
||||
if (tv && reached >= tv) { // the tail a wait went ahead of is through: how long it took from there
|
||||
uint64_t d = kern_now_ns() - __atomic_load_n(&tail_t0, __ATOMIC_RELAXED), a = tail_ns;
|
||||
@@ -1064,7 +1065,7 @@ static void completion_main(void *arg) {
|
||||
plat_cond_broadcast(&cv_done);
|
||||
for (uint64_t v = reached - was > GW_RING ? reached - GW_RING + 1 : was + 1; v <= reached; v++) gw_mark(v, 2);
|
||||
plat_mutex_unlock(&st_lock);
|
||||
vk_mem_collect();
|
||||
vk_mem_collect_try();
|
||||
plat_mutex_lock(&st_lock);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user