~88,800 Create*View per frame on a 4070; a CPU-heap copy cache hits 76% (measurement and a lead) #1161

Closed
opened 2026-11-26 03:58:41 +00:00 by github-bot · 1 comment
Owner

@⁠xunbreakablex on GitHub · 2026-11-25 22:08 UTC · original

Needs human attention: one machine, one run per arm, and the speed number is for a package of four switches, so this is a measurement of how often the layer creates views and a lead, not a proposal to merge anything.

AI-assisted (Claude); runs on my machine: RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz (6 cores), Windows 11, driver 621.01, Series X profile. Tree: 465b94f plus a few switched-off commits of mine (diagnostics build), steady window world +300..+480 s.

How many views the layer creates. Every shader-visible slot gets its descriptor from a fresh Create*View (descriptor/host.rs: make(), buffer_srv/buffer_uav, raw_at/raw_uav_at, constant_at, the null_* helpers); CopyDescriptorsSimple is used only to fill new heaps with null views. With a counter on those calls: about 88,800 Create*View per frame at ~4,700 draws in the cell scene. vkd3d-proton's author measured a view creation at 50-100x the cost of a descriptor copy (https://themaister.net/blog/2021/11/), and Flamingo (FLAMINGO.md, run 93/94) put the driver's descriptor making at ~8.6% of the frame. As far as I can find, no open PR here caches created views (#807 fixes HostHeap::copied invalidation, a different thing).

What a cache does. I wrote a switch, off by default, that creates each distinct SRV/UAV (optionally CBV) once in a CPU-only heap, keyed by exactly what the create call would receive (host resource, view description; address and size for CBVs), and fills slots with CopyDescriptorsSimple. Entries hold a reference on their resource, are forgotten when the resource's host copy is dropped, and are swept after 2 unused frames; the table is bounded. In the run: 69,400 views per frame copied from the cache, 22,100 created (76% hits).

Speed: I only have it inside a package with three other switches (CARD_HASH_WIDE from #1014, INDIRECT_GATHER, a barrier-group deferral of mine that turned out to do almost nothing): 144.9 ms vs 162.5 ms per frame for the same set without the four (−17.6 ms, one run each). I cannot say how much of that is the view cache; #1014's own effect on the card is large in the same run. A run with the view cache alone is next.

Picture: the cell-window shot looked the same in both runs by the measures I use (black ratio, a stair-edge measure); a stale copy would show as wrong or flickering textures, which I did not see in one run.

The branch is local; I can push it if someone wants to try it or wants the counter alone.

**@⁠xunbreakablex** on GitHub · 2026-11-25 22:08 UTC · [original](https://github.com/fxceless/victory-fork/issues/1161) **Needs human attention:** one machine, one run per arm, and the speed number is for a package of four switches, so this is a measurement of how often the layer creates views and a lead, not a proposal to merge anything. AI-assisted (Claude); runs on my machine: RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz (6 cores), Windows 11, driver 621.01, Series X profile. Tree: `465b94f` plus a few switched-off commits of mine (diagnostics build), steady window world +300..+480 s. **How many views the layer creates.** Every shader-visible slot gets its descriptor from a fresh `Create*View` (`descriptor/host.rs`: `make()`, `buffer_srv`/`buffer_uav`, `raw_at`/`raw_uav_at`, `constant_at`, the `null_*` helpers); `CopyDescriptorsSimple` is used only to fill new heaps with null views. With a counter on those calls: **about 88,800 `Create*View` per frame** at ~4,700 draws in the cell scene. vkd3d-proton's author measured a view creation at 50-100x the cost of a descriptor copy (https://themaister.net/blog/2021/11/), and Flamingo (FLAMINGO.md, run 93/94) put the driver's descriptor making at ~8.6% of the frame. As far as I can find, no open PR here caches created views (#807 fixes `HostHeap::copied` invalidation, a different thing). **What a cache does.** I wrote a switch, off by default, that creates each distinct SRV/UAV (optionally CBV) once in a CPU-only heap, keyed by exactly what the create call would receive (host resource, view description; address and size for CBVs), and fills slots with `CopyDescriptorsSimple`. Entries hold a reference on their resource, are forgotten when the resource's host copy is dropped, and are swept after 2 unused frames; the table is bounded. In the run: **69,400 views per frame copied from the cache, 22,100 created (76% hits)**. **Speed:** I only have it inside a package with three other switches (`CARD_HASH_WIDE` from #1014, `INDIRECT_GATHER`, a barrier-group deferral of mine that turned out to do almost nothing): 144.9 ms vs 162.5 ms per frame for the same set without the four (−17.6 ms, one run each). I cannot say how much of that is the view cache; #1014's own effect on the card is large in the same run. A run with the view cache alone is next. **Picture:** the cell-window shot looked the same in both runs by the measures I use (black ratio, a stair-edge measure); a stale copy would show as wrong or flickering textures, which I did not see in one run. The branch is local; I can push it if someone wants to try it or wants the counter alone.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:41 +00:00
Author
Owner

@⁠xunbreakablex on GitHub · 2026-11-26 07:25 UTC · original

Result of the run I said was next, and a correction (AI-assisted, Claude; RTX 4070 (undervolted), Ryzen 5 5600 at 3.95 GHz, same binary as above, one warm-up run discarded, then one run each, steady window world +300..+480 s):

frame per 1,000 draws views created by the device / copied from the cache / misses
base set 143.6 ms (sd 5.0) 32.4 ms 88,964 / 0 / 0
base set + view cache 142.0 ms (sd 7.9) 33.9 ms 20,509 / 66,941 / 5,248

So the cache cuts the device's view creation by 77% but the frame does not move (-1.6 ms, inside the noise): on this machine creating views is not on the critical path. Correction: the "144.9 vs 162.5 ms" in the issue text was almost certainly run-to-run drift, not the package: today's base-set run alone gave 143.6 ms. I am closing this as measured and not worth pursuing here; the view counts stay above in case they are useful to someone profiling the descriptor path.

**@⁠xunbreakablex** on GitHub · 2026-11-26 07:25 UTC · [original](https://github.com/fxceless/victory-fork/issues/1161#issuecomment-7185446414) Result of the run I said was next, and a correction (AI-assisted, Claude; RTX 4070 (undervolted), Ryzen 5 5600 at 3.95 GHz, same binary as above, one warm-up run discarded, then one run each, steady window world +300..+480 s): | | frame | per 1,000 draws | views created by the device / copied from the cache / misses | |---|---|---|---| | base set | 143.6 ms (sd 5.0) | 32.4 ms | 88,964 / 0 / 0 | | base set + view cache | 142.0 ms (sd 7.9) | 33.9 ms | 20,509 / 66,941 / 5,248 | So the cache cuts the device's view creation by 77% but the frame does not move (-1.6 ms, inside the noise): on this machine creating views is not on the critical path. **Correction:** the "144.9 vs 162.5 ms" in the issue text was almost certainly run-to-run drift, not the package: today's base-set run alone gave 143.6 ms. I am closing this as measured and not worth pursuing here; the view counts stay above in case they are useful to someone profiling the descriptor path.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/fxceless--victory-fork#1161
No description provided.