One empty texture block made ahead by a thread of ours #684

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

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


Stacked on #683 (and so on #630). New here: the last two commits, One empty texture block made ahead by a thread of ours and its bench.

Why

With VICTORY_RIPE_BLOCKS=0, the launcher's setting, the thread that placed a texture no block had room for made the new 64 MiB block itself, and waited until it was resident and mapped.

What

When a texture takes the last empty block and the texture queue has room (resource::room_lately), a thread of ours (victory-block-ahead) makes the next one. VICTORY_BLOCK_AHEAD=0: none, as before.

  • At most one block more than the textures hold, which the pool keeps as a spare anyway (SPARE).
  • If the pool already has an empty block by the time it's made, the new one is released.
  • With ripe blocks on, Pool::finish makes blocks ahead itself, so this is left out.
  • The memory-waits line from #630 counts how many were made ahead.

Before / after

bench_textures_that_need_new_blocks (--ignored --nocapture, VICTORY_RIPE_BLOCKS=0): one 16 MiB texture placed every 4 ms, four to a block. RTX card, four runs each. The first texture makes the first block either way (7.7–9.9 ms). For the 95 placements after it:

mean 99th percentile longest
placing thread makes each block (VICTORY_BLOCK_AHEAD=0) 0.36–0.41 ms 1.57–1.92 ms 1.66–1.95 ms
a block made ahead 0.050–0.061 ms 0.11–0.16 ms 0.135–0.185 ms

Correctness

  • an_empty_block_is_made_ahead_once_none_is_left (meant for VICTORY_RIPE_BLOCKS=0; it skips itself otherwise): once textures took every empty block, an empty block is there within 5 s, it is one made ahead (the counter moved), and the thread that made it has ended.
  • The pool tests pass with VICTORY_RIPE_BLOCKS unset and =0, and with this switch on and off. The made-ahead test passed in five repeated runs. With the debug layer on it reports nothing.
  • CI steps run locally on this branch: clippy in both builds with -D warnings is clean. cargo test --workspace --locked passes, apart from the two watch::tests guard tests that fail now and then, which they also did in 1 of 10 runs on unchanged main.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5536263666 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/684). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T03:32:47Z. --- **Stacked on #683** (and so on #630). New here: the last two commits, `One empty texture block made ahead by a thread of ours` and its bench. ## Why With `VICTORY_RIPE_BLOCKS=0`, the launcher's setting, the thread that placed a texture no block had room for made the new 64 MiB block itself, and waited until it was resident and mapped. ## What When a texture takes the last empty block and the texture queue has room (`resource::room_lately`), a thread of ours (`victory-block-ahead`) makes the next one. `VICTORY_BLOCK_AHEAD=0`: none, as before. - At most one block more than the textures hold, which the pool keeps as a spare anyway (`SPARE`). - If the pool already has an empty block by the time it's made, the new one is released. - With ripe blocks on, `Pool::finish` makes blocks ahead itself, so this is left out. - The memory-waits line from #630 counts how many were made ahead. ## Before / after `bench_textures_that_need_new_blocks` (`--ignored --nocapture`, `VICTORY_RIPE_BLOCKS=0`): one 16 MiB texture placed every 4 ms, four to a block. RTX card, four runs each. The first texture makes the first block either way (7.7–9.9 ms). For the 95 placements after it: | | mean | 99th percentile | longest | |---|---|---|---| | placing thread makes each block (`VICTORY_BLOCK_AHEAD=0`) | 0.36–0.41 ms | 1.57–1.92 ms | 1.66–1.95 ms | | a block made ahead | 0.050–0.061 ms | 0.11–0.16 ms | 0.135–0.185 ms | ## Correctness - `an_empty_block_is_made_ahead_once_none_is_left` (meant for `VICTORY_RIPE_BLOCKS=0`; it skips itself otherwise): once textures took every empty block, an empty block is there within 5 s, it is one made ahead (the counter moved), and the thread that made it has ended. - The pool tests pass with `VICTORY_RIPE_BLOCKS` unset and `=0`, and with this switch on and off. The made-ahead test passed in five repeated runs. With the debug layer on it reports nothing. - CI steps run locally on this branch: clippy in both builds with `-D warnings` is clean. `cargo test --workspace --locked` passes, apart from the two `watch::tests` guard tests that fail now and then, which they also did in 1 of 10 runs on unchanged `main`.
0xkn0wh3r3 commented 2026-11-28 06:49:49 +00:00 (Migrated from github.com)

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


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:7235543889 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/684#issuecomment-7235543889). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T06:49:49Z. --- 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!684
No description provided.