Skip to content

CPU-bound frames: read-back lock fix, drop causes and refresh census, opt-in APU async and upload headroom - #3271

Open
B0tis wants to merge 9 commits into
trustno1-coder:mainfrom
B0tis:pr/rtx3070-cpu-findings
Open

B0tis wants to merge 9 commits into
trustno1-coder:mainfrom
B0tis:pr/rtx3070-cpu-findings

Conversation

@B0tis

@B0tis B0tis commented Nov 29, 2026 •

Copy link
Copy Markdown

[pr-performance] [pr-diagnostics]

What it changes

In heavy open-world scenes the frame is CPU-bound: lowering the render resolution does not raise fps. This PR removes one lock that held list threads up, adds two cheap log lines that show where the CPU time goes, and adds two opt-in switches. Defaults change nowhere except the lock fix and the log lines.

Fix

  • Read backs no longer hold the pool's lock while a buffer is created (Host::read_back_buffer). The lock was held across CreateCommittedResource, even with the pool off, so every list thread that closed a list with read backs waited for the other threads' buffer creations. This hurts most under host memory pressure, when read-back buffers are made anew every frame.

Diagnostics (release builds, every 5 s)

  • dropped draws and dispatches by cause, per frame: every silent exit in prepare_for, bind, rectangles and dispatch now records a cause (no pipeline, root, table slots, memory views, index, builder stage off, …). This separates real losses from expected ones. In the scenes measured, nearly all drops were ray-tracing builder stages that are switched off.
  • refresh census per frame and refresh census by kind per frame (VICTORY_REFRESH_CENSUS=0 turns them off):
    • the host copies with the most refreshed bytes;
    • per kind (write-watched or guarded, with or without a card copy): updates, MB and ms;
    • the asking time, split into three parts: waiting for another thread's asking, the kernel's write watch, and the guards.

Opt-in switches (off by default)

  • VICTORY_TEXTURE_FIRST_UPLOAD_CARD_HEADROOM_MB=<MB>: first uploads leave this much of the card's budget free. The existing 80% ceiling counts texture copies only, so a burst of first uploads can fill a small card, and every upload after it waits. On 8 GB cards, 768 kept the upload queue moving.
  • VICTORY_APU_ASYNC=1: each XApu connection gets a worker thread that produces the results (Opus decode, conversion), as the console's audio processor does. The title dequeues a result once it is ready. This takes most of a core's work off the title's busiest thread. Whether fps rises depends on whether that thread limits the frame.

Bench

  • bench.ps1 -SeriesS and -Dlss ultraperformance.

How it was tested

Notes for further CPU work (not part of the diff)

  • Existing switches that helped in the bench:

    • VICTORY_READ_BACK_POOL=1
    • TABLE_SAME, ROOT_SAME, ROOT_TAILS, THIN_COALESCE
    • VICTORY_SETTLE_UNLOCKED=1: in WPR, the submitting thread's waits inside submit fell from 67 to 11.5 ms/s.
  • No gain or worse in the bench:

    • more or fewer list threads (THIN_THREADS)
    • TITLE_AFFINITY, SUBMIT_CORE_ALONE
    • KEEP_GUARD_LOCK + ALIAS_DIRECT
    • LAZY_COMPARE
  • Where the time goes: on a timeline of heavy frames, the critical chain was spread across these:

    • long list calls;
    • threads woken but not yet running (CPU oversubscription);
    • refreshes;
    • translation of single big lists on one thread;
    • the card itself.

    The card's idle time is mostly the submitting thread. Only about 7% of lists repeat word for word, so translation reuse would not pay.

  • Guarded view memory: the streamed windows, remapped page by page, are the costliest kind of refresh. The cost is guards-mutex contention and VirtualProtect under the lock, not copying.

  • Tried for guarded view memory and dropped:

    • Leaving hot blocks unguarded: they never became clean, so every asking took the slow path.
    • A try-lock in publish(): publishings were skipped and refreshes got slower.
    • A lock-free "open for the frame" state: whole 64 KiB blocks were copied instead of 4 KiB parts.

    In-place reads are not possible for these windows (scattered single 64 KiB views). For the constants heap they lose on Ampere (Renderer port #1 (VICTORY_PORT_CONSTANTS=1) on Ampere: the submitting thread saves ~9 ms, but the card waits ~25 ms a frame on the in-place heap #1223).

Checked for overlap

🤖 Generated with Claude Code

B0tis and others added 9 commits November 29, 2026 21:59
… the buffer's creation

Host::read_back_buffer took its POOL mutex for the whole call, with the pool off
too, so every list thread closing a list with read backs waited for the others'
CreateCommittedResource. A WPR profile (RTX 3070 + 5800X3D, 2026-11-29) had the
six list threads waiting 302 ms a second there, for the ocean's texture read
backs under memory pressure. Bench (same save, Series S, DLSS performance, no
frame generation): VICTORY_READ_BACK_POOL=1 alone 15.85 -> 16.5 fps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b3c12cf4e89a90cc3f3a213ee133d7b6d6025d5f)
Each silent exit of prepare_for, bind, rectangles and dispatch names its cause
on its thread; every drop counts it. A new line 'dropped draws and dispatches by
cause, per frame' follows the frame line. Runs on an RTX 3070 (2026-11-29)
dropped ~2,400 of 7,000-9,800 draws a frame for a minute at a time, with only
the total to go by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1b9a9a326ee91f116c17406b147cd54184738d30)
…me (VICTORY_REFRESH_CENSUS, on)

Every 5 s: MB refreshed per frame in all, in how many copies, how much of it
not write-watched, and the 12 largest copies (title address, size, MB, ms and
refreshes per frame). Refreshes cost 21-28 ms a frame for 60-70 MB on an RTX
3070 + 5800X3D, about 2.5 GB/s, and nobody knew which buffers they are (the
council of 2026-11-29, step 4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 952f62e32c9e64c4d4c7fec71359e898133053b7)
…ite-watched, card copy or not

A second line every 5 s: per kind of host copy (write-watched or guarded, with
or without a copy in the card's memory) the updates, those that copied, MB, ms,
and of them the ms asking the write watch and the guards what was written. The
6 MB windows refresh at ~0.5 GB/s and the constants heap at ~2.7 GB/s on an RTX
3070 + 5800X3D; this says whether asking or copying takes the time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9facfcad779b9985476e41282b694905ac89cad5)
…, the kernel's write watch and the guards

Guarded copies (view memory) spent ~65 of ~80 ms a frame (summed over threads)
asking what was written on an RTX 3070 + 5800X3D, and VICTORY_GUARD_HOT=50 did
not lower it, so re-protecting is not the cost. The census by kind now splits
the asking three ways.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit fb758b6c02d3c09fa1ce93f828897311ab9694a2)
…_FIRST_UPLOAD_CARD_HEADROOM_MB)

The 80% ceiling weighs texture copies alone (main's fix for render targets
counted twice), so with the pool off only the whole-card guard was left, at
100% of the budget: a burst of first uploads filled an RTX 3070 to 6,881 of
7,109 MB and every upload after it waited. Default 0 (as before); play-small
sets 768.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 357146a1a10c2980974253eee2042a0532acdb4f)
…_APU_ASYNC=1)

XApuEnqueueCommand decoded each command (Opus, conversion) on the title's thread
that queued it. A WPR CPU profile of an RTX 3070 + 5800X3D run (2026-11-29) had
the title's busiest thread running 870 ms a second, 330 of them in
XApuEnqueueCommand decoding Opus. With the switch, a connection's thread
(victory-apu) takes the commands in order and makes their results, as the
console's audio processor does beside the title; the title dequeues them once
made (PENDING_RESULTS until then, or the connection's event). Off unless asked
for; without it the commands are made at once as before, through the same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f97a1dd3cba1a6c18f3843787d4d8e1da78b61ba)
For the 8 GB profile (Series S, play --series-s) and DLSS ultra performance,
which play accepts since trustno1-coder#1115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tics builds, sort_by_key)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the pr-performance Pull request: makes it faster or use less memory label Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-performance] RTX 3070 8 GB: read-back lock fix, drop causes, refresh census, opt-in APU async and first-upload headroom RTX 3070 8 GB: read-back lock fix, drop causes, refresh census, opt-in APU async and first-upload headroom Nov 29, 2026
@B0tis B0tis changed the title RTX 3070 8 GB: read-back lock fix, drop causes, refresh census, opt-in APU async and first-upload headroom [pr-performance] CPU-bound frames: read-back lock fix, drop causes and refresh census, opt-in APU async and upload headroom Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-performance] CPU-bound frames: read-back lock fix, drop causes and refresh census, opt-in APU async and upload headroom CPU-bound frames: read-back lock fix, drop causes and refresh census, opt-in APU async and upload headroom Nov 29, 2026
Broodguy pushed a commit to Broodguy/VIctory-NVIDIA that referenced this pull request Nov 29, 2026
…ock fix (port trustno1-coder#3271)

Port of upstream PR trustno1-coder#3271 (B0tis, open). apu.rs merged with a 3-way apply
onto our scratch-buffer port (4671109): the worker's run() keeps the
reused Opus PCM scratch.

- VICTORY_APU_ASYNC=1 (off unless given; the launcher sets it): each XApu
  connection gets a "victory-apu" thread that makes the results (Opus decode,
  conversion), as the console's audio processor does; the title dequeues a
  result once made (PENDING_RESULTS until then). The PR's CPU profile (RTX
  3070 + 5800X3D) had the title's busiest thread at 870 ms/s, 330 of them in
  Opus decoding inside XApuEnqueueCommand. Aimed at the audio crackle: the
  decode no longer waits behind a title thread that is late at 6-15 fps.
- Host::read_back_buffer no longer holds the pool's lock across
  CreateCommittedResource (default; list threads closing lists with read
  backs waited on each other, worst under memory pressure).
- Drop causes per frame and the refresh census in the 5 s lines; the census
  is OFF by default here (VICTORY_REFRESH_CENSUS=1 turns it on): it takes a
  global lock for every refresh that copies.
- VICTORY_TEXTURE_FIRST_UPLOAD_CARD_HEADROOM_MB=<MB>: opt-in, off.

- The connections' threads run at VICTORY_APU_PRIORITY (default 2, HIGHEST,
  like the XMA decoder; new here).

Expected: audio: fewer underruns when the title's threads are busy; fps:
0-2 ms where the title's audio thread limits the frame, plus the read-back
lock. Switches: VICTORY_APU_ASYNC (0/unset = decode at enqueue, as before).
Shader preload: not needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@madvillain91

madvillain91 commented Nov 29, 2026 •

Copy link
Copy Markdown

System Information:

  • GPU: NVIDIA GeForce RTX 3070 Ti 8GB
  • Windows 11 Pro, Build 26300.9711

Summary of Test Session:

  • FPS: Held almost static at 15 FPS in open world.
  • Gameplay/Feel: No stutter spikes, hitches, lock-ups, or severe micro-pauses detected. Performance was extremely consistent, even if capped/low. Movement (vehicular/on-foot) remained smooth for the full session.
  • Stability: No crash or freeze. Game started cleanly; no device errors, read-back lock errors, or submission issues in log.
  • Visuals: Asset streaming, shadow rendering, and LOD selection appeared stable. No new artefacts detected.

Technical Highlights from Log:

  • All "queue," "frame," "async," "lock," and "read-back" log lines completed without warning or error.
  • The system utilized VICTORY_ASYNC_SUBMIT (async submit logic) and managed frames/submissions according to PR goals.
  • Median/p95 frametimes (GPU-side) were extremely low (1–2 ms, p99 up to 12 ms), indicating true CPU-side cap or scheduler bottleneck, not a rendering/sync bug.
  • Log indicates subtle improvement in frame pacing—frames presented and dispatched in sync, little evidence of CPU-GPU sync slippage or excessive flushes.

Notes/Outcome:

    • Game is now very consistent and stable from a CPU submission perspective.
  • – Overall FPS is unusually capped/low for this GPU, but this appears unrelated to submission, lock, or read-back errors.
  • Would recommend investigating further or combining with profiling/optimization PRs to push FPS up while maintaining current smoothness and stability.

Attachment:
victory-nvidia-play-20261129-231142-33492.log

ForthtuN added a commit to ForthtuN/VIctory-NVIDIA that referenced this pull request Nov 29, 2026
…load buffer churn

Selective upstream trustno1-coder#1279, trustno1-coder#3271 and trustno1-coder#3411. Preserve list identity, refusal diagnostics, memory caps, critical commit purge, shader translator and cache keys. Include upstream planner and spare retention tests; run targeted host tests in CI.
JustOptimize added a commit to JustOptimize/VIctory-Enhanced that referenced this pull request Nov 30, 2026
… opt-in APU async and upload (PR trustno1-coder#3271)

Port of trustno1-coder#3271, one conflict in shadow.rs update_free: kept this branch's prev load (for the guarded/unguarded decision) with the PR's timing around watch::writes (LAST_ASK_US). Host::read_back_buffer no longer holds the pool's lock across CreateCommittedResource; every silent exit in prepare_for, bind, rectangles and dispatch records a cause, shown as 'dropped draws and dispatches by cause, per frame' every 5 s; 'refresh census per frame' and 'by kind' lines (VICTORY_REFRESH_CENSUS=0 turns them off); two opt-in APU switches in hle apu.rs (off by default); bench.ps1 reads the new lines. Defaults change nowhere except the lock fix and the log lines. Upstream: scene measurements on a CPU-bound open-world frame, no frame-rate figure.
JustOptimize added a commit to JustOptimize/VIctory-Enhanced that referenced this pull request Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request: makes it faster or use less memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants