Staging blocks made with the pool's lock let go #685

Closed
0xkn0wh3r3 wants to merge 11 commits from upstream-pr/685 into main
0xkn0wh3r3 commented 2026-11-28 03:32:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T03:32:49Z.


Stacked on #684 (and so on #683 and #630). It edits the same function, take_unlocked. New here: the last two commits, Staging blocks made with the pool's lock let go and its bench.

Why

A new 64 MiB block of texture staging is upload memory, which the system zeroes before it's there. It was made under the staging pool's lock, so every texture upload waited to be staged in the meantime.

What

The staging pool makes its blocks the same way texture blocks are made in #683, with the lock released, through one helper (take_from) for both pools. VICTORY_BLOCKS_UNLOCKED=0 puts both back under their locks, as before. The backoff for refused blocks, and the gate on speculative prefetch, are kept.

Before / after

bench_staging_while_another_thread_makes_blocks (--ignored --nocapture): one thread stages 64 KiB pieces while another stages 8 MiB pieces and keeps 64 of them, so new staging blocks keep being made. RTX card, four runs each. Latency of the small pieces' staging:

mean longest
block made under the lock (VICTORY_BLOCKS_UNLOCKED=0) 1.0–3.7 ms 504–2,532 ms (a whole block's making, waited for)
lock released 0.000–0.040 ms 0.007–40 ms (a small piece that found no room either)

Correctness

  • threads_that_stage_at_once_get_zeroed_pieces_of_their_own: eight threads stage 64 MiB each at once, making new blocks. Every piece starts as zeros and holds only what its own thread wrote (sampled every 4 KiB, since the CPU reads write-combined memory slowly).
  • The made-ahead test from #684 skips itself with blocks made under the lock, where nothing is made ahead.
  • The pool tests pass with VICTORY_RIPE_BLOCKS unset and =0, and with VICTORY_BLOCKS_UNLOCKED=0. With the debug layer on it reports nothing.
  • CI steps run locally on this branch: clippy in both builds with -D warnings, and cargo test --workspace --locked, all pass.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5536263949 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/685). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T03:32:49Z. --- **Stacked on #684** (and so on #683 and #630). It edits the same function, `take_unlocked`. New here: the last two commits, `Staging blocks made with the pool's lock let go` and its bench. ## Why A new 64 MiB block of texture staging is upload memory, which the system zeroes before it's there. It was made under the staging pool's lock, so every texture upload waited to be staged in the meantime. ## What The staging pool makes its blocks the same way texture blocks are made in #683, with the lock released, through one helper (`take_from`) for both pools. `VICTORY_BLOCKS_UNLOCKED=0` puts both back under their locks, as before. The backoff for refused blocks, and the gate on speculative prefetch, are kept. ## Before / after `bench_staging_while_another_thread_makes_blocks` (`--ignored --nocapture`): one thread stages 64 KiB pieces while another stages 8 MiB pieces and keeps 64 of them, so new staging blocks keep being made. RTX card, four runs each. Latency of the small pieces' staging: | | mean | longest | |---|---|---| | block made under the lock (`VICTORY_BLOCKS_UNLOCKED=0`) | 1.0–3.7 ms | 504–2,532 ms (a whole block's making, waited for) | | lock released | 0.000–0.040 ms | 0.007–40 ms (a small piece that found no room either) | ## Correctness - `threads_that_stage_at_once_get_zeroed_pieces_of_their_own`: eight threads stage 64 MiB each at once, making new blocks. Every piece starts as zeros and holds only what its own thread wrote (sampled every 4 KiB, since the CPU reads write-combined memory slowly). - The made-ahead test from #684 skips itself with blocks made under the lock, where nothing is made ahead. - The pool tests pass with `VICTORY_RIPE_BLOCKS` unset and `=0`, and with `VICTORY_BLOCKS_UNLOCKED=0`. With the debug layer on it reports nothing. - CI steps run locally on this branch: clippy in both builds with `-D warnings`, and `cargo test --workspace --locked`, all pass.
Dukestar69 commented 2026-11-28 05:18:09 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T05:18:09Z.

Review: APPROVED


LGTM — verified on Windows (RTX 5090):

  • cargo test -p victory-gpu --lib pool:: passed (12/12, including concurrent staging/texture block creation tests)
  • 0 new compiler warnings in touched files
  • cargo xtask policy passed (294 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6095975725 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/685#pullrequestreview-6095975725). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T05:18:09Z. **Review:** APPROVED --- LGTM — verified on Windows (RTX 5090): - `cargo test -p victory-gpu --lib pool::` passed (12/12, including concurrent staging/texture block creation tests) - 0 new compiler warnings in touched files - `cargo xtask policy` passed (`294 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
0xkn0wh3r3 commented 2026-11-28 06:49:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T06:49:51Z.


Replaced by #816, one smaller change of the same kind (blocks made with the pool's lock let go, for both textures and staging). It has no switch and no separate thread making blocks ahead, and comes with before/after numbers against current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7235544216 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/685#issuecomment-7235544216). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T06:49:51Z. --- Replaced by #816, one smaller change of the same kind (blocks made with the pool's lock let go, for both textures and staging). It has no switch and no separate thread making blocks ahead, and comes with before/after numbers against current main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!685
No description provided.