Defer residency candidate construction until a migration tick #221

Manually merged
github merged 1 commit from github-bot/gh-221 into main 2026-12-03 17:20:12 +00:00 AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-02 19:12 UTC · original
tommiehansen:perf/residency-migration-cadence → main · +60 −19 · 1 files · 1 commits · merged 2026-12-03 17:15 UTC

The residency worker builds vectors of candidates on housekeeping ticks where it cannot migrate pages. It also linearly searches a pool snapshot by ID and sorts candidates by weight even when every one fits the budget.

The snapshot preserves slot identity for indexed lookup. Heat sampling, age, scores, cooldowns and retirements still run on their existing schedules. Migration ticks use the same priority order when budget selection is required. The emitted ranges stay in the original address order, with the original placement calls and fence sequence.

The expected effect is lower CPU cost and fewer allocations on high-activity residency ticks. The branch passed Windows-target Rust checking with and without diagnostics. An extracted differential test covered 33,408 input-size and budget pairs, including tied weights and the maximum batch length.

Expected work reduction

Operation Previous Updated
Non-migration housekeeping tick Build migration candidate vectors Skip candidate construction
Pool lookup Linear snapshot search Indexed lookup
All candidates fit Sort by weight Skip unnecessary priority sort

This is a worker-side CPU optimization, not a change to migration eligibility or a guarantee of higher resident bytes. Evaluate alongside, but independently of, #303, which changes optional ranking.

Hardware testing

Hardware benchmarking was unavailable. Please compare migration counts, worker CPU time and frame-time tails at native 1080p on RX 9060 XT 16 GB and native 1440p on RX 9070 XT under Linux, with RT enabled and frame generation disabled, especially when streaming under VRAM pressure.

**@⁠tommiehansen** on GitHub · 2026-12-02 19:12 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/221) `tommiehansen:perf/residency-migration-cadence` → `main` · +60 −19 · 1 files · 1 commits · merged 2026-12-03 17:15 UTC The residency worker builds vectors of candidates on housekeeping ticks where it cannot migrate pages. It also linearly searches a pool snapshot by ID and sorts candidates by weight even when every one fits the budget. The snapshot preserves slot identity for indexed lookup. Heat sampling, age, scores, cooldowns and retirements still run on their existing schedules. Migration ticks use the same priority order when budget selection is required. The emitted ranges stay in the original address order, with the original placement calls and fence sequence. The expected effect is lower CPU cost and fewer allocations on high-activity residency ticks. The branch passed Windows-target Rust checking with and without diagnostics. An extracted differential test covered 33,408 input-size and budget pairs, including tied weights and the maximum batch length. ## Expected work reduction | Operation | Previous | Updated | |---|---|---| | Non-migration housekeeping tick | Build migration candidate vectors | Skip candidate construction | | Pool lookup | Linear snapshot search | Indexed lookup | | All candidates fit | Sort by weight | Skip unnecessary priority sort | This is a worker-side CPU optimization, not a change to migration eligibility or a guarantee of higher resident bytes. Evaluate alongside, but independently of, [#303](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/303), which changes optional ranking. ## Hardware testing Hardware benchmarking was unavailable. Please compare migration counts, worker CPU time and frame-time tails at native 1080p on RX 9060 XT 16 GB and native 1440p on RX 9070 XT under Linux, with RT enabled and frame generation disabled, especially when streaming under VRAM pressure.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:28:04 +00:00
github-bot force-pushed github-bot/gh-221 from 87993c77b0 to 0b3d41517d 2026-12-02 19:33:58 +00:00 Compare
github manually merged commit 0d0c1623ef into main 2026-12-03 17:20:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.