XGameRuntime: reject duplicate queued async work #2514

Open
loyodea wants to merge 1 commit from upstream-pr/2524 into main
loyodea commented 2026-11-25 21:35:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by loyodea on 2026-11-25T21:35:14Z.


Related to #576. The fallback XAsyncSchedule accepts a second work item while the first is still pending, returning S_OK twice. Reserve one queued item per operation and return E_UNEXPECTED for the duplicate, matching libHttpClient. Release the reservation at worker entry and after a refused submission so providers can reschedule or retry.

What is in it

  • xasync.rs: one pending-work reservation and five synthetic tests for immediate and delayed duplicates, XAsyncRun, rescheduling, and retry. README.md documents the behavior.

Tested

  • Windows 11 Pro 26300, Ryzen 7 5700X3D, Radeon RX 9060 XT driver 32.0.32029.2010, Rust 1.100.0 GNU x64, DXC 1.9.2609.5, debug.
  • At 86e392f, cargo build --locked --workspace --jobs 5 passed. cargo test --locked --jobs 5 -p xcl --lib hle::xgameruntime::xasync::tests -- --test-threads=4 reported 19 passed, 0 failed, 0 ignored. Three duplicate tests failed and the two controls passed before the fix on the original base.
  • cargo test --locked --jobs 5 --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1,424 passed, 4 failed, and 46 ignored. The synthetic end-to-end title passed. Eight SKIPPED notices covered six unsupported per-lane paths, driver-cache measurement without Developer Mode, and the opt-in heap-window OOM path.
  • The four GPU failures also reproduced on earlier clean upstream 0829441: fuzz_validate_and_gpu_1 (seed 722), fuzz_validate_and_gpu_3 (seed 1599), directed_reference_basics, and f64_programs_on_the_gpu. The fuzz failures match #2115.

Regression run

Paired real-title scripts/smoke.ps1 results are pending. This draft remains blocked on the required smoke runs.

Not tested

MSVC and release builds, retail titles, other GPU vendors, and the installed PC runtime forwarding path. Issue #576 also reports block lifetime, queue lifetime, and completion-wait behavior, which this change leaves outside its scope.

AI use

OpenAI Codex investigated the contract, wrote the patch, synthetic tests, and description, and ran the checks at the contributor's direction. The exact model used for the original patch was unavailable.

<!-- greyfinch-sync:ivall/xcl:issue:5499563798 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2524). Originally posted by [loyodea](https://github.com/loyodea) on 2026-11-25T21:35:14Z. --- Related to #576. The fallback `XAsyncSchedule` accepts a second work item while the first is still pending, returning `S_OK` twice. Reserve one queued item per operation and return `E_UNEXPECTED` for the duplicate, matching libHttpClient. Release the reservation at worker entry and after a refused submission so providers can reschedule or retry. **What is in it** - `xasync.rs`: one pending-work reservation and five synthetic tests for immediate and delayed duplicates, `XAsyncRun`, rescheduling, and retry. `README.md` documents the behavior. **Tested** - Windows 11 Pro 26300, Ryzen 7 5700X3D, Radeon RX 9060 XT driver 32.0.32029.2010, Rust 1.100.0 GNU x64, DXC 1.9.2609.5, debug. - At `86e392f`, `cargo build --locked --workspace --jobs 5` passed. `cargo test --locked --jobs 5 -p xcl --lib hle::xgameruntime::xasync::tests -- --test-threads=4` reported 19 passed, 0 failed, 0 ignored. Three duplicate tests failed and the two controls passed before the fix on the original base. - `cargo test --locked --jobs 5 --workspace --no-fail-fast -- --test-threads=4 --nocapture` reported 1,424 passed, 4 failed, and 46 ignored. The synthetic end-to-end title passed. Eight SKIPPED notices covered six unsupported per-lane paths, driver-cache measurement without Developer Mode, and the opt-in heap-window OOM path. - The four GPU failures also reproduced on earlier clean upstream `0829441`: `fuzz_validate_and_gpu_1` (seed 722), `fuzz_validate_and_gpu_3` (seed 1599), `directed_reference_basics`, and `f64_programs_on_the_gpu`. The fuzz failures match #2115. **Regression run** Paired real-title `scripts/smoke.ps1` results are pending. This draft remains blocked on the required smoke runs. **Not tested** MSVC and release builds, retail titles, other GPU vendors, and the installed PC runtime forwarding path. Issue #576 also reports block lifetime, queue lifetime, and completion-wait behavior, which this change leaves outside its scope. **AI use** OpenAI Codex investigated the contract, wrote the patch, synthetic tests, and description, and ran the checks at the contributor's direction. The exact model used for the original patch was unavailable.
DavidM1911 commented 2026-11-25 22:06:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T21:54:07Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7175684540 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2524#issuecomment-7175684540). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T21:54:07Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
xpatfussy69x commented 2026-11-25 23:09:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T22:21:43Z.


Test run on exact head 86e392f (86e392fd3a9d33099e3f72ec16b646bbe3dd34c8, on its base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1428 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib async_schedule: 5 passed, 0 failed
  • This PR's new tests in the workspace run:
    • async_schedule_rejects_duplicate_queued_work: ok
    • async_schedule_rejects_duplicate_delayed_work: ok
    • async_schedule_allows_rescheduling_from_do_work: ok
    • async_schedule_rejected_submit_can_be_retried: ok
    • async_schedule_rejects_work_already_queued_by_run: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 86e392fd3a9d33099e3f72ec16b646bbe3dd34c8
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1131 (PresentX 1131)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14788 MB

No crash or device removal; frames 104 % of main's, peak commit 100 %.

Not tested

  • Whether the title schedules the same async work twice in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
<!-- greyfinch-sync:ivall/xcl:comment:7176266470 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2524#issuecomment-7176266470). Originally posted by [xpatfussy69x](https://github.com/xpatfussy69x) on 2026-11-25T22:21:43Z. --- Test run on exact head `86e392f` (`86e392fd3a9d33099e3f72ec16b646bbe3dd34c8`, on its base `6d12f58`), clean tree. **Tested** - NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs - `cargo test --workspace -- --test-threads=4`: 1428 passed, 0 failed, 46 ignored - SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` (on `main` too) - `cargo test -p xcl --lib async_schedule`: 5 passed, 0 failed - This PR's new tests in the workspace run: - `async_schedule_rejects_duplicate_queued_work`: ok - `async_schedule_rejects_duplicate_delayed_work`: ok - `async_schedule_allows_rescheduling_from_do_work`: ok - `async_schedule_rejected_submit_can_be_retried`: ok - `async_schedule_rejects_work_already_queued_by_run`: ok **Regression run** (60 s, default settings, a retail title) main: ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1091 (PresentX 1091) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14814 MB ``` this PR: ``` xcl-smoke v1 commit: 86e392fd3a9d33099e3f72ec16b646bbe3dd34c8 gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1131 (PresentX 1131) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14788 MB ``` No crash or device removal; frames 104 % of `main`'s, peak commit 100 %. **Not tested** - Whether the title schedules the same async work twice in this run: a regression check only - The PR merged into current `main` (tested on its own base; it merges into `e1d84b7` without conflicts) - AMD / native wave64 **AI use** - Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
SlopTart commented 2026-11-25 23:09:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T22:49:54Z.


Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of the new async_schedule_* tests (five): all passed. XGameRuntime, CPU-side, fine under the Wine lane.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7176837678 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2524#issuecomment-7176837678). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T22:49:54Z. --- **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of the new `async_schedule_*` tests (five): all passed. XGameRuntime, CPU-side, fine under the Wine lane. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
loyodea commented 2026-11-26 18:53:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by loyodea on 2026-11-26T18:53:28Z.


Thanks for testing this on Windows and Wine. The exact-head Windows run passed all five scheduling tests and the 60-second smoke run finished without a crash or device removal. The Wine run also passed all five scheduling tests after merging with main.

<!-- greyfinch-sync:ivall/xcl:comment:7200964284 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2524#issuecomment-7200964284). Originally posted by [loyodea](https://github.com/loyodea) on 2026-11-26T18:53:28Z. --- Thanks for testing this on Windows and Wine. The exact-head Windows run passed all five scheduling tests and the 60-second smoke run finished without a crash or device removal. The Wine run also passed all five scheduling tests after merging with `main`.
Foniass commented 2026-12-01 08:16:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:16:26Z.


Triage (#1607) – head 86e392f

No open or merged PR makes the same change. Main's XAsyncSchedule has no work_scheduled guard, and the other open PRs touching xasync.rs (#641, #670, #1406) do not add one.
No problems found in the diff. XAsyncRun goes through XAsyncSchedule, so it sets the flag too. do_work_cb clears it before calling the provider, so a reschedule from DoWork works. A failed submit clears it again.
The README line describes an internal detail rather than something users can do. Consider dropping it.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305100139 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2524#issuecomment-7305100139). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:16:26Z. --- **Triage (#1607)** – head 86e392f No open or merged PR makes the same change. Main's `XAsyncSchedule` has no `work_scheduled` guard, and the other open PRs touching `xasync.rs` (#641, #670, #1406) do not add one. No problems found in the diff. `XAsyncRun` goes through `XAsyncSchedule`, so it sets the flag too. `do_work_cb` clears it before calling the provider, so a reschedule from DoWork works. A failed submit clears it again. The README line describes an internal detail rather than something users can do. Consider dropping it. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2524:upstream-pr/2524'
git switch 'upstream-pr/2524'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2524'
git switch 'upstream-pr/2524'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2524'
git switch 'upstream-pr/2524'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2524'
git switch 'main'
git merge --squash 'upstream-pr/2524'
git switch 'main'
git merge --ff-only 'upstream-pr/2524'
git switch 'main'
git merge 'upstream-pr/2524'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
xcl-dev/xcl!2514
No description provided.