Repository navigation
perf(vk): a buffer binding checks the left-out ranges without the shared lock - #119
Merged
Merged
Conversation
…red lock With RX_VK_CAP_ONLY_GPU on (the default) every gpu_buffer_bind asks cap_excl_hit whether the binding reaches into memory left out of the captures, before its per-thread memo: about ten times a draw on each of the parallel replay's recording threads, and each ask took cap_excl_mu, one mutex for all of them. The ranges change only when the capture list is rebuilt or a pool is made; each thread now keeps its own copy and takes it again under the lock only when cap_excl_gen, bumped at both changes, has moved. The answers and the diagnostics they feed are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks, I read the whole diff: the generation bump under the lock at both change sites and the per-thread copy look right. It touches the Windows renderer, so I'll build it and test it in game on Windows before merging; the machines are busy with measurements right now, so it'll be a little later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
RX_VK_CAP_ONLY_GPUon (the default), everygpu_buffer_bindcallscap_excl_note, which askscap_excl_hitwhether the binding reaches into memory left out of the captures (engine/gpu/vk/vk_memory.cpp). It asks before its per-thread memo, so it runs on every binding: uniform, storage, vertex and index buffers, about ten a draw, on each of the parallel replay's recording threads. Each ask tookcap_excl_mu, one mutex shared by all of them.The ranges change in only two places: the capture list's rebuild (
cap_excl.swap) and a new pool (cap_pool_born_now). Both now bumpcap_excl_genunder the lock.cap_excl_hitkeeps a thread-local copy of the ranges and takes it again under the lock only when the generation has moved. The answers, and the counts and log linescap_excl_notemakes from them, are unchanged.docs/SWITCHES.mdandengine/docs/switches.jsonare regenerated (python -I engine/scripts/list_switches.py): their "Read at" line numbers invk_memory.cppmoved.Measured (Linux, RX 9070 XT, RADV Mesa 26.2.6, Ryzen 5 5500X3D 6 cores / 12 threads)
Interleaved A/B, 4 rounds per area, order rotated each round, 60 s windows, uncapped, scratch saves, power profile
performance, no contaminated runs. A = main 6b7fde7, B = this branch (same code as the build measured):Zora's replay, where the most buffers are bound, is ~9% shorter; Kokiri's frame rate is within noise. Not measured: Windows, NVIDIA, or other CPUs (the gain should be larger with more recording threads contending, but that is a guess).
Tests:
python -I -B tests/run_all.pyinengine/: 489 passed;tests/test_switches_documented.pypasses after the regeneration;nx2/test_nup_read_name.pyfails here and on main alike (nozstandardmodule on this PC).🤖 Generated with Claude Code