perf: batch completed host-list recycling #650

Open
github-bot wants to merge 8 commits from github-bot/gh-650 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-05 23:49 UTC · original
tommiehansen:perf/batch-list-recycle-20261206 → main · +547 −2 · 2 files · 8 commits · draft

Why

Retiring completed host command lists currently returns each list to the idle pool individually. When many lists complete together, repeated lock acquisitions and membership searches can add CPU overhead and contention during command recording/submission.

What changes

Batch completed-list recycling with one idle-pool lock for the batch, bounded membership tracking (allocation-free up to 64 lists), and the original path for batches below 16. Preserve fence completion, reset, capacity and retained-resource lifetime; no asynchronous reaper. Inspired by CNF/Larp #185, implemented against XMEM's own lifecycle. Remains opt-in.

Benchmark results — Windows WARP, four concurrent workers

CI 47586706004, e6bca39. Eight ABBA/BAAB blocks per shape, 64 worker durations per arm, exact reuse oracle. Absolute values are medians of block medians; percentage is median paired change; p95 is pooled worker duration.

Shape Before After Paired change Wins p95 before → after
Small 180.03 µs 179.28 µs +24.13% 3/8 751.9 → 724.1 µs
Mixed 267.13 µs 265.38 µs +0.07% 4/8 1551.0 → 1312.2 µs
Wide 895.25 µs 421.03 µs −43.08% 6/8 2435.2 → 2348.4 µs

Wide paired changes range from −96.48% to +115.58%; contention results are noisy. Earlier uncontended CI found −7.67% recycling time / −2.55% measured-phase sum at 16 lists and −1.75% / +2.13% at 32. Lock acquisitions fall from 32 to 2 for 16 lists (operation counts, not a timing claim).

Why this should be merged

Wide concurrent retirement is promising and the patch preserves the existing lifecycle. However, the small control and mixed workload do not establish robust overall benefit. Keep draft pending better contention-aware admission and repeatable net-cost evidence.

Validation and compatibility

Initial actual reuse 6/6 completed and reused exactly; subsequent 16 completed and 16 reused from 20 total, plus current four-worker test and both Windows configurations pass.
Reproduce: cargo test --locked --release -p victory-gpu --features diagnostics --lib recycle_concurrent_paired_tail_cost -- --ignored --nocapture --test-threads=1. Native AMD/title command-list batch distribution and frame-time tails remain unmeasured.

Current revision 264219f

Admission now requires overlapping eligible retirement calls, rather than batching every large uncontended retirement. A scoped activity guard restores the count on exit; shallow and disabled paths remain unchanged. The concurrent fixture now records actual activation, checks small/off controls and requires activation for the wide case. The serial fixture checks original lock counts. The table above measures the preceding revision; current-head CI 47589117773 has completed.

Verified adaptive-admission benchmark

CI 47589117773 passed both jobs at 264219f. Eight paired blocks per shape, exact reuse and admission controls. Recomputed medians of block medians:

Shape Before (µs) After (µs) Paired median Wins
Small 94.325 72.000 −24.12% 5/8
Mixed 257.925 232.325 −13.29% 5/8
Wide 347.050 35.575 −66.44% 6/8

Wide paired changes range from −96.35% to +900.91%. Small never activates yet also appears faster; this is evidence of scheduling noise. Keep draft: persistent-worker contention and aggregate retirement throughput remain necessary before making a robust benefit claim.

Persistent-worker validation

Current head 169bd74 adds persistent workers, synchronized already-completed retirement, four repetitions per measured arm, aggregate retired lists, elapsed retirement, release-to-end, start spread, worker p95 and actual batch-admission counts. Every repetition requires exact readback and recycled identity set. CI 47592042102 is running; no timing claim until completed.

**@⁠tommiehansen** on GitHub · 2026-12-05 23:49 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/650) `tommiehansen:perf/batch-list-recycle-20261206` → `main` · +547 −2 · 2 files · 8 commits · draft ## Why Retiring completed host command lists currently returns each list to the idle pool individually. When many lists complete together, repeated lock acquisitions and membership searches can add CPU overhead and contention during command recording/submission. ## What changes Batch completed-list recycling with one idle-pool lock for the batch, bounded membership tracking (allocation-free up to 64 lists), and the original path for batches below 16. Preserve fence completion, reset, capacity and retained-resource lifetime; no asynchronous reaper. Inspired by CNF/Larp #185, implemented against XMEM's own lifecycle. Remains opt-in. ## Benchmark results — Windows WARP, four concurrent workers [CI 47586706004](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47586706004), `e6bca39`. Eight ABBA/BAAB blocks per shape, 64 worker durations per arm, exact reuse oracle. Absolute values are medians of block medians; percentage is median paired change; p95 is pooled worker duration. | Shape | Before | After | Paired change | Wins | p95 before → after | |---|---:|---:|---:|---:|---:| | Small | 180.03 µs | 179.28 µs | +24.13% | 3/8 | 751.9 → 724.1 µs | | Mixed | 267.13 µs | 265.38 µs | +0.07% | 4/8 | 1551.0 → 1312.2 µs | | Wide | 895.25 µs | 421.03 µs | −43.08% | 6/8 | 2435.2 → 2348.4 µs | Wide paired changes range from −96.48% to +115.58%; contention results are noisy. [Earlier uncontended CI](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47585710976) found −7.67% recycling time / −2.55% measured-phase sum at 16 lists and −1.75% / +2.13% at 32. Lock acquisitions fall from 32 to 2 for 16 lists (operation counts, not a timing claim). ## Why this should be merged Wide concurrent retirement is promising and the patch preserves the existing lifecycle. However, the small control and mixed workload do not establish robust overall benefit. Keep draft pending better contention-aware admission and repeatable net-cost evidence. ## Validation and compatibility [Initial actual reuse](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47582163831) 6/6 completed and reused exactly; subsequent 16 completed and 16 reused from 20 total, plus current four-worker test and both Windows configurations pass. Reproduce: `cargo test --locked --release -p victory-gpu --features diagnostics --lib recycle_concurrent_paired_tail_cost -- --ignored --nocapture --test-threads=1`. Native AMD/title command-list batch distribution and frame-time tails remain unmeasured. ### Current revision `264219f` Admission now requires overlapping eligible retirement calls, rather than batching every large uncontended retirement. A scoped activity guard restores the count on exit; shallow and disabled paths remain unchanged. The concurrent fixture now records actual activation, checks small/off controls and requires activation for the wide case. The serial fixture checks original lock counts. The table above measures the preceding revision; [current-head CI 47589117773](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47589117773) has completed. ### Verified adaptive-admission benchmark [CI 47589117773](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47589117773) passed both jobs at 264219f. Eight paired blocks per shape, exact reuse and admission controls. Recomputed medians of block medians: | Shape | Before (µs) | After (µs) | Paired median | Wins | |---|---:|---:|---:|---:| | Small | 94.325 | 72.000 | −24.12% | 5/8 | | Mixed | 257.925 | 232.325 | −13.29% | 5/8 | | Wide | 347.050 | 35.575 | −66.44% | 6/8 | Wide paired changes range from −96.35% to +900.91%. Small never activates yet also appears faster; this is evidence of scheduling noise. Keep draft: persistent-worker contention and aggregate retirement throughput remain necessary before making a robust benefit claim. ### Persistent-worker validation Current head `169bd74` adds persistent workers, synchronized already-completed retirement, four repetitions per measured arm, aggregate retired lists, elapsed retirement, release-to-end, start spread, worker p95 and actual batch-admission counts. Every repetition requires exact readback and recycled identity set. [CI 47592042102](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47592042102) is running; no timing claim until completed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 23:56:21 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/650/head:github-bot/gh-650'
git switch 'github-bot/gh-650'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-650'
git switch 'github-bot/gh-650'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-650'
git switch 'github-bot/gh-650'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-650'
git switch 'main'
git merge --squash 'github-bot/gh-650'
git switch 'main'
git merge --ff-only 'github-bot/gh-650'
git switch 'main'
git merge 'github-bot/gh-650'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.