native: follow each wrapped range once per pass, not once per heap entry (follow-up to #267) #319
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/319"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T11:16:05Z.
Follow-up to #267 (Refs #258), answering the cost question asked there.
What it cost.
follow_title_pageschecked each heap entry's signature on its own. But the title copies the same descriptor into many slots of the shader-visible heap. At the 1,000th pass of a world run, we followed 696 large entries:So each pass walked the same mappings dozens of times, under the pool-table lock.
Fix. Within one pass, the signature is computed once per distinct
(base, end)range and reused for every entry over it.Numbers (M5 Pro, release). These come from an
#[ignore]harness with that entry mix, synthetic addresses and sizes, and 1,000, 10,000 or 100,000 other one-page mappings in the table, in the common case where the generation changed but nothing under the views did:The cost per range is linear in the mappings under it: 13–28 ns each (the 174 MiB range is 36–78 µs). The table's other mappings barely matter, since the lookup is log n.
That world run made about 12 passes a second: 900 in 73 s. The pool table changes about 2,600 times a second, but a pass happens only once per submission. So the cost drops from about 37 ms of CPU a second, with the pool lock held about 3 ms per pass, to under 1 ms a second.
Tests:
native::tests::copies_of_a_wrapped_view_are_followed_with_one_walk: three copies of a wrapped view, then a change elsewhere in the table, make 1 signature walk instead of 3. Without the memo the test fails (3 vs 1). After a remap under the view it is still 1 walk, and the copy the program reads follows the remap, checked on the GPU.memory::signature_timing::signature_walks_of_a_follow_pass(#[ignore]), documented as a regression measure with the command to run it.Checks: victory-gpu 320 tests pass (2 ignored), Windows clippy is clean with
-D warnings,cargo xtask policypasses, anddocs/native-host.mdis updated.Later, if needed: a per-range generation in
PoolTable, so a pass only re-walks ranges a change touched.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:15Z.
Thank you for answering the cost question with a table and a test. A pass that walks each range once is a clear improvement, and I agree with the memo being per pass.
I have not run it. I will include it in my next combined run (with #263, #264, #253 and #278) and say what the run shows. One request: in the description, point to the world run the "696 large entries" were counted in (commit and switches), so I can compare against my own.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T12:40:11Z.
The "696 large entries" come from this world run (M5 Pro 48 GB, Series S, windowed, 300 s):
following the title's pages under heap buffer views looks=1000 generation=321276, at 09:38:37Z.c1b95875+ #253 (first head,8ebef857) + #264 (5ec1d4e7) + #267's revision. That revision was a WIP commit with the same code asca22c393, apart from docs.VICTORY_TRACE_TARGETS=1,VICTORY_DUMP_TARGETS=<dir>,110,20, andVICTORY_KEYSpressing Enter every 3 s, viarun-native.sh --seconds 300 --console series-s.