perf(gpu): texture read-backs written by a thread of their own #7

Manually merged
github merged 1 commit from github-bot/gh-7 into main 2026-11-26 17:20:08 +00:00 AGit
Owner

@⁠Indy2l on GitHub · 2026-11-26 16:55 UTC · original
Indy2l:perf/landing-split → main · +186 −26 · 3 files · 1 commits · merged 2026-11-26 17:18 UTC

Problem

texback::land runs on the thread that lands submissions. It takes watch::title_memory_reading() before writing the water maps into title memory. While the world streams, the title changes mappings constantly, and on the 16 GB machine from #6 that wait stood at 124–416 ms per frame in some stretches, for 2–10 maps of 350 KB. Every other submission's landing waited with it.

Change

  • Finer timing: "read-backs and lists" in the landing line is split into texture read-backs, buffer read-backs, and the flights' card plans and own work. Texture read-backs were the whole of it.
  • Off the landing thread: the landing thread now only copies a read-back's texels out of its buffer. Waiting for the locks, tiling and writing into title memory go to a thread of their own.
  • Newest copy wins: of several copies of one allocation waiting there, only the newest is written. The title reads the frame before at most, as the module's comment already allows.
  • A switch: VICTORY_TEXBACK_ASYNC=0 writes them where they land, as before.
  • A fallback: if the thread can't be started, they're written inline.
  • A new log line: the writer's lock waits and work per frame.

Validation

  • Build and tests: cargo build --locked --profile diag -p victory --features diagnostics, and cargo test --locked -p victory-gpu --lib (331 passed, including only_readbacks_for_changed_allocations_are_invalidated).
  • In game, same machine, Series S at 540p with VICTORY_WINDOWS_BAR_MB=3072, 7- and 8-minute runs:
    • texture read-backs on the landing thread went from up to 416 ms per frame to under 3 ms
    • the writer still waits up to 320–500 ms some frames, which no longer holds up landings
    • windows under 2 fps went from 6–14 per run to 3, with 17 under 5 fps
    • median fps barely moved (8.6–9.2). The remaining stalls are the title paging (see #6).

Not covered: a check that boats still float as well as before. The written data is unchanged, but it can now arrive a frame later.

🤖 Generated with Claude Code

**@⁠Indy2l** on GitHub · 2026-11-26 16:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/7) `Indy2l:perf/landing-split` → `main` · +186 −26 · 3 files · 1 commits · merged 2026-11-26 17:18 UTC ## Problem `texback::land` runs on the thread that lands submissions. It takes `watch::title_memory_reading()` before writing the water maps into title memory. While the world streams, the title changes mappings constantly, and on the 16 GB machine from #6 that wait stood at 124–416 ms per frame in some stretches, for 2–10 maps of 350 KB. Every other submission's landing waited with it. ## Change - **Finer timing:** "read-backs and lists" in the landing line is split into texture read-backs, buffer read-backs, and the flights' card plans and own work. Texture read-backs were the whole of it. - **Off the landing thread:** the landing thread now only copies a read-back's texels out of its buffer. Waiting for the locks, tiling and writing into title memory go to a thread of their own. - **Newest copy wins:** of several copies of one allocation waiting there, only the newest is written. The title reads the frame before at most, as the module's comment already allows. - **A switch:** `VICTORY_TEXBACK_ASYNC=0` writes them where they land, as before. - **A fallback:** if the thread can't be started, they're written inline. - **A new log line:** the writer's lock waits and work per frame. ## Validation - **Build and tests:** `cargo build --locked --profile diag -p victory --features diagnostics`, and `cargo test --locked -p victory-gpu --lib` (331 passed, including `only_readbacks_for_changed_allocations_are_invalidated`). - **In game,** same machine, Series S at 540p with `VICTORY_WINDOWS_BAR_MB=3072`, 7- and 8-minute runs: - texture read-backs on the landing thread went from up to 416 ms per frame to under 3 ms - the writer still waits up to 320–500 ms some frames, which no longer holds up landings - windows under 2 fps went from 6–14 per run to 3, with 17 under 5 fps - median fps barely moved (8.6–9.2). The remaining stalls are the title paging (see #6). Not covered: a check that boats still float as well as before. The written data is unchanged, but it can now arrive a frame later. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
"read-backs and lists" in the landing line is split into texture
read-backs, buffer read-backs and the flights' card plans and own work.
On a 16 GB machine with an RTX 3060 (Series S, 540p) the texture part
stood at 1-2 ms a frame, and at 124-416 ms in the frames where the world
streamed: texback::land waits for the lock against mapping changes
(watch::title_memory_reading), which the title changes all the time
then, and the landing of every submission waited with it.

The landing thread now only copies a read-back's texels out of its
buffer; waiting for the locks, tiling and writing into title memory go
to a thread of their own, which writes only the newest of several
copies of one allocation (the title reads the frame before at most).
VICTORY_TEXBACK_ASYNC=0 writes them where they land, as before. A new
line gives the writer's waits and work per frame.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:57:12 +00:00
github manually merged commit ce6b2545e7 into main 2026-11-26 17:20:08 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.