Skip to content

\ GPU: capped view heap - more title blocks,waiting views skip the sync\ - #7

Merged
wbkepler merged 1 commit into
mainfrom
gpu/heap-block-starvation
Nov 25, 2026
Merged

wbkepler merged 1 commit into
mainfrom
gpu/heap-block-starvation

Conversation

@wbkepler

Copy link
Copy Markdown
Owner

Problem

On a host that caps shader-visible view heaps (NVIDIA: 1,000,000 slots), the capped-view-heap remap (Marvisak#1779 upstream) gives the title's views host slots by 1,024-slot blocks. In the world, the title holds views in about 990–1,006 of its 1,216 blocks, and most of those blocks are dense (~590 hold more than 512 views). The heap had only 703 host blocks left beside 262,144 dynamic slots, and the world never used more than ~111,500 dynamic slots at once (~111,500 while loading, 55,000–77,000 after).

So ~309,000 live views had no host slot. Every sync visited them again on each dirty page (~57,000 visits per frame), and each visit searched the whole block map for a free block. Finer blocks would not help: even counted in 64-slot chunks, the views need ~930k slots.

Change (host only; translated shaders and the shader cache key are unchanged)

  • Capped hosts get 2^17 dynamic slots instead of 2^18, which leaves 831 host blocks for title views instead of 703.
  • A view that finds no host block now waits, keyed by its record:
    • while the title leaves it unchanged, the sync skips it;
    • while no block is free, the search for one returns at once;
    • when its block gets a host block, or one is given back, the waiting views are made (a few blocks per sync, the block with the most waiting views first);
    • if a waiting view goes stale, it stops waiting.
  • Diagnostics builds log block use, waiting views, block ages, dynamic-slot peaks and sync_heaps time every 5 s.

Measured (RTX 5090, 300 s, same keys and cache as the v4 runs)

before (041b8ee) after
live title views without a host slot ~309,000 ~101,000
visits to them per frame ~57,000 ~11,000
host blocks 703 831
sync_heaps ms/frame ~65 ~52
dynamic-slot peak (of capacity) 111,517 / 262,144 110,979 / 131,072
world fps ~2.5 ~2.4 (noise; GPU slightly higher)

The run had no device removal. Camera timing differs between runs, so the world captures are not like-for-like; no regression is visible.

Open

  • The title still wants ~160 blocks more than the heap holds. Block ages show that the waiting blocks are rewritten as recently as the mapped ones, so this is a real working set, not a stale tail. Plain LRU eviction would thrash and could evict persistent tables that are read only through heap indexing. Closing the gap needs read information or a different layout (e.g. per-slot indirection).
  • At load, the dynamic slots now peak at 85% of the smaller range.

Tests: the existing capped-heap tests pass (two expectations updated for the smaller dynamic range), and there is a new test, a_view_without_a_host_block_waits_for_one. Gate: clippy (gpu + victory diagnostics), cargo test -p victory-gpu -- --test-threads=1 (179 passed), cargo xtask policy.

🤖 Generated with Claude Code

On a host that caps shader-visible view heaps (NVIDIA, 1,000,000 slots)
the title's views get host slots by 1,024-slot blocks. In the world the
title holds views in ~990-1,006 of its 1,216 blocks (mostly dense: ~590
blocks hold >512 views; finer blocks would not help, 64-slot chunks still
need ~930k slots), but only 703 host blocks were left beside 262,144
dynamic slots, of which the world took at most ~111,500 (55,000-77,000
after loading). ~309,000 live views had no host slot, and every sync
visited them again on each dirty page (~57,000 visits per frame), each
searching the whole block map for a free block.

- Capped hosts get 2^17 dynamic slots (host only; shaders and the
  shader cache key are unchanged): 831 host blocks instead of 703.
- A view that finds no host block waits with its record's key: the sync
  skips it while the title leaves it unchanged, the search returns at
  once while no block is free, and waiting views are made as soon as
  their block has a host block or one is given back (a few blocks per
  sync, the block with the most waiting first).
- Diagnostics builds log block use, waiting views, block ages, dynamic
  slot peaks and sync time every 5 s.

Measured in the world (RTX 5090, 300 s): views without a host slot
~309,000 -> ~101,000, their visits ~57,000 -> ~11,000 per frame,
sync_heaps ~65 -> ~52 ms per frame, no device removal.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@wbkepler
wbkepler merged commit 1104646 into main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant