Keep retired resources in groups by submission stamp #463
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!463
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-463"
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?
@Indy2l on GitHub · 2026-11-30 01:44 UTC · original
Indy2l:retire-groups→main· +60177 −5428 · 206 files · 660 commits · closed without mergingSummary
retireandretire_resourcekeep what they let go in 16 shards, each sorted by the submission count the object waits for. When an entry arrived with a stamp below the shard's newest,insert_retiredput it in the middle of the shard's oneVecDeque. That moves every newer entry along, under the shard's lock, and withbury_lag()keeping retired views for 16 or 64 more submissions, a shard holds thousands. It happens often: the stamp isSTARTED + queued(), read from two counters, andHostHeap::keepretires the old resource of every slot whose resource changes, most of them frommake_listed.Each shard now keeps one group per stamp (
Shard: aVecDeque<(u64, Vec<Retired>)>, oldest first), so a late entry is appended to its own group, andmerge_retired_batchinserts each batched entry the same way.burydrains whole groups and drops them outside the lock as before. Up to 4 emptied groups per shard are kept for reuse, so a frame's groups don't grow from nothing.Nothing about what is dropped, when, or in what order changes: by stamp, and within one stamp in the order retired, exactly as the single sorted queue held them.
RTX 3060 12 GB, i5-12400F, 16 GB, Series S,
-Machine 3060(3 workers)A CPU profile (WPR, 60 s, sampled at 1 kHz) taken standing still at the window where the prologue first gives control, without touching the stick, before and after this change. Both builds were on
fe7c6e5+ #395 (which only changes static sampler order, so the pipeline cache stays warm across launches and the two runs compare), with the play script's own-Machine 3060settings. Share of all sampled stacks ofvictory.exe:VecDeque::insertfrominsert_retiredretire_resourcein totalThe after-build also had a second, local change (taking a reference only when a descriptor slot changes resource, the same as the
keep_refin #272), so the totals below are of both together: list translation (thin::Recording::run) fell from 1.78 to 1.62 cores, and the layer's own CPU per frame from about 308 to 285 ms, while the title's own code stayed at about 255 ms a frame. The frame rate at that spot did not change beyond the spread of runs (12.5 fps standing, 12.4 and 12.8 during the two profiles): those threads were not what the frame waited for there. The saving is CPU time, which should matter where the CPU is busier.Verification
cargo clippy --locked --workspace --all-targetsand the same with--all-features: clean.cargo test --locked --workspace: no failures (victory-gpulib 529 passed). In some parallel runs one ofwatch::tests::a_raw_copy_in_watched_memory_keeps_the_other_asked_rangesorhost::refresh_tests::raw_title_copy_keeps_write_watch_and_resends_equal_bytesfails, onfe7c6e5without this change as well (the flake of #443/#449); both pass alone and with--test-threads=1.cargo test --locked --workspace --all-features -- --test-threads=1: no failures (victory-gpulib 596 passed).host::retire_batch_tests:groups_drop_in_the_order_of_one_sorted_queue(the drop order with late entries, a group inserted in the middle, a batch, and reused groups) andgroups_let_go_what_the_single_queue_did(the old queue, kept in the test as it was, against the new shards over 200 random sequences of in-order, late and batched retirements and partial buries: the same entries let go at every bury, in the same order). With the group insert changed on purpose to put a late entry first, the second test fails.a_late_batch_does_not_hide_eligible_retirementsis kept, adapted to the new type.cargo run -p xtask --locked -- policy: 322 files ok.git diff --check: clean.scripts\play.ps1 -Machine 3060 -Console series-s -Windowed -More @{VICTORY_OUTPUT='1920x1080'; VICTORY_UPSCALER='6'; VICTORY_RENDER_SCALE='0.5'}on the build described above, the prologue route with a stand-still of about 4 minutes at the window,wpr -start CPU -filemodefor 60 s during it. No difference in the picture was noticed while playing, and none is expected: no object is let go at a different time. The profiles were taken onfe7c6e5+ #395 rather than plainfe7c6e5because on plainfe7c6e5this PC recompiles a varying set of static-sampler pipelines at each launch (#423), which would still be running at that spot in some runs. Recordings stay local.🤖 Generated with Claude Code
@Kal0s-design on GitHub · 2026-11-30 02:01 UTC · original · reviewed
Read the diff against main. The grouping keeps the old drop order:
Shard::insertappends to the stamp's own group, found at the back or bypartition_point(at < stamp), and opens a new group at the sorted place only when the stamp has none. Within a stamp the order is the order retired, which is what the oldpartition_point(at <= stamp)insert gave.merge_retired_batchstill does a stable sort, then inserts each entry the same way. That matches the old split-and-merge, and the randomizedgroups_let_go_what_the_single_queue_didcompares both over mixed in-order, late and batched retirements and partial buries.burystill drops outside the shard lock, oldest group first. The second lock to hand back emptied groups happens only for shards that let something go.RETIREDgoes throughinsert_retiredormerge_retired_batch(retire, the latebackpaths,flush_retired), so none of them still assumes a flat queue.Two small points, neither blocking:
shrink_tocap if memory shows it.VecDeque::insert, now among groups rather than entries, which is what removes the 2.5%.CI is green; I didn't rerun the profile.
AI-assisted: yes
@Indy2l on GitHub · 2026-11-30 02:36 UTC · original
Thanks for reading it against main.
On the spare groups: the single
VecDequethis replaces also kept its peak capacity per shard, and that peak held every live entry across all stamps, so the spares don't add a new kind of retention. The bound is small in numbers too: an entry is 24 bytes, so a spare that once held 20,000 entries is about 0.5 MB, and 64 of them at most about 30 MB. I'm looking at the process's memory on this 16 GB PC at the moment; if the spares show up there, I'll add ashrink_tocap in a follow-up.On the middle insert: yes, a stamp with no group yet still goes in with
VecDeque::insert, now moving the few groups of newer stamps instead of their thousands of entries.@Indy2l on GitHub · 2026-11-30 16:23 UTC · original
Closing this: the new main (the NVIDIA rebuild) no longer has the cost it fixed. There,
retireandretire_resourceonlypush_backonto the calling thread's shard: no sorted insert among newer stamps and no batch merge, which is what moved thousands of entries under the lock in our profile. Thanks!Pull request closed