i9-14900K + RX 9070 XT at a59f3e5: 6.5 fps standing still; the card is busy ~54% and the submitting thread waits on fences ~43% (profile) #163
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD#163
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ThiagoTodeschini on GitHub · 2026-11-25 18:02 UTC · original
Thanks for
a59f3e5: on this machine it took the same spot from 4.5 to 6.5 fps. Here is where the time goes now, in case it helps with the next step.Machine: Intel Core i9-14900K (8 performance + 16 efficiency cores, 32 threads), AMD Radeon RX 9070 XT 16 GB (driver 32.0.32029.2010), 32 GB DDR5-4800, Windows 11 (26200), Series X profile.
Build:
a59f3e5merged into a fork whose only code changes place threads on hybrid processors (https://github.com/ThiagoTodeschini/VIctory-AMD-Intel; standing still they make no measurable difference),diagprofile with-C target-cpu=native, shader cache warm.Scene: the same save, standing still at the same spot, about 4,800 to 5,000 draws a frame. Medians of the 5-second summary lines:
01aadd1a59f3e5The card: the process's 3D engine is busy about 54% (Windows "GPU Engine" counter, 6 s sample), so the frame is not bound by the GPU.
VICTORY_PROFILE(one 20 s window, 11,682 samples of the submitting thread):Host::wait_fence(host.rs:1186) underTimeline::step(timeline.rs:186), reached fromqueue::executeandqueue::signal2_xMutex::lock_contendedonself.submitted(host.rs:1286), and 9% underdrain_in_flight_locked(host.rs:1294)bindless_planabout 6%,Shadow::update_lazily6%,Shadow::copy_back6%,watch::writes_guarded4%,Instant::nowwith the performance counter about 3%, and 1.2% inZwCreateThreadEx(the scoped threadsin_parallelstarts on each call)Threads (CPU time over 20 s): the process uses about 4.3 cores; one title thread at about 74% of a core (41% of it in the kernel), five at 47 to 49%, one at 27%;
victory-queues8%.So the submitting thread and the card mostly take turns. With async submission the title's recording overlaps the card, but
execute_innerstill drains the previous submission beforepreparetouches the shared host copies, so the next submission's preparation and the card's work do not overlap. Versioned (double-buffered) host copies for the ranges an in-flight submission reads, or per-range hazard tracking so a prepare waits only when it touches what the in-flight lists read, look like the next step; you know the constraints far better.Tried here without gain (
01aadd1unless noted, same spot):VirtualQuery,ReadProcessMemory)VICTORY_SHADER_LOOP_LIMIT=4096: no change, so the GPU time is not runaway loopsdiagnostics(a59f3e5): no change--console series-s: +13%, for a softer pictureThe profile file and the logs are available if useful.
@ySKELLETONX on GitHub · 2026-11-26 13:01 UTC · original
Thanks for the profile. I read the path it points at on
main4f62c2a; here is where the 43% inwait_fenceseems to come from, and a direction to ask about before anyone writes it.Where the submitting thread waits
queue::signal/signal2_xpush anOp::Signal, andTimeline::step(timeline.rs) runs it on the calling thread:Op::Workdoes the same. So withVICTORY_ASYNC_SUBMIT,execute_titlereturns before the card is done, but the title's nextSignalon that queue blocks the title's thread until the card has finished and the copy-back (finish_submission) is done. The asynchronous part covers only the time betweenExecuteCommandListsand the followingSignal, which for this title is usually right after. That fits "the submitting thread and the card mostly take turns", and the 12% contention onsubmitted(wait_fencetakes it on the title's thread while other paths want it).A direction: title fences signalled by a completion thread
Instead of waiting in the op, a
Signalthat follows unfinished work would be handed to one thread that:SetEventOnCompletion),submittedand runsreap_completed(copy-back, bottom-of-pipe writes, burying), aswait_fencedoes now,The order the title can see stays the same (its fence is reached only after what the work wrote is back in its memory), but
Signalreturns at once, and the title's thread goes on recording while the card runs.Op::Waiton another queue already re-checksfence.reached, so it would just wait for the completion thread instead of finishing the work itself (finishinstep).What I don't know and you do:
Signalhaving finished the work by the time it returns (the comment atsignal2_xsays "our submissions are complete when they return");execute_innerstill draining the previous submission beforeprepare. If the title waits on the fence it just signalled before recording more, the gain is small, and the double-buffered host copies you mention would be the bigger step. A trace of the title'sSignalandWaitvalues in one frame would show which it is.If that direction sounds right, I can prototype it on a branch with correctness tests (ordering, copy-back before the signal, a lost device while a signal is pending), and @ThiagoTodeschini could measure it at the same spot. I can't measure in the world myself.
A small piece now
In the same profile, 1.2% went to
ZwCreateThreadEx:in_parallelstarts its threads withstd::thread::scopeon every call. I opened #253 to keep five threads instead. Start and join per call goes from about 280 µs to under 1 µs here (Ryzen 7 5700X3D, release).@ySKELLETONX on GitHub · 2026-11-26 14:12 UTC · original
@ThiagoTodeschini, you offered the profile file: could you attach it (or the
VICTORY_PROFILEoutput with the stacks)? Two things I can't settle from the summary:Instant::nowat about 3%. It costs about 35 ns a call here (Ryzen 7 5700X3D), so 3% of a 153 ms frame would be on the order of 130,000 calls a frame on the submitting thread. The timing I can find on the release path runs once or twice per copy step, refreshed range or title-memory copy (run_deferred,update,watch::writing): thousands a frame, well under 0.1 ms. Thediagbuild adds one percopy_mapped(copystat), and the title's ownQueryPerformanceCountercalls would land in the same frame, so the callers decide whether there is anything to take out. You also saw no change in fps with a release build withoutdiagnostics, which points the same way.Shadow::update_lazily,Shadow::copy_back(6% each) andwatch::writes_guarded(4%). Which callers they come from, and whether it is a few large ranges or many small ones, would show where to look next.Meanwhile the two smaller pieces are up: #258 (
wait_fenceno longer holdssubmittedwhile it waits for the card, the 12% contention) and #253 (in_parallelon kept threads, the 1.2% inZwCreateThreadEx). If you get the chance, the same spot with them would show what they give back in the world; I can't measure there.