XGameRuntime: XTaskQueueIsEmpty counts delayed callbacks not yet due #1681

Open
github-bot wants to merge 1 commit from github-bot/gh-1681 into main AGit
Owner

@⁠emirduran707 on GitHub · 2026-11-24 19:14 UTC · original
emirduran707:taskqueue-is-empty-delayed → main · +23 −1 · 1 files · 1 commits · open

XTaskQueueIsEmpty looked only at a port's queued items and the callbacks in flight. A callback submitted with a delay (XTaskQueueSubmitDelayedCallback, or XAsyncSchedule with a delay) waits in the task queue's timer heap until it is due, so while it waited the port read as empty. libHttpClient's task queue, which XTaskQueue is, counts those entries. TaskQueuePortImpl::IsEmpty is (m_queueList->empty()) && (m_pendingList->empty()) && (m_processingCallback == 0), and a delayed entry goes to m_pendingList (TaskQueue.cpp).

A title that dispatches until the port is empty before it terminates a queue, or that uses XTaskQueueIsEmpty to tell whether its timers are done, stopped too early. The delayed callback then ran canceled at termination.

XTaskQueueIsEmpty now also looks for the queue's entries on that port in the timer heap. The locks are taken in the order submit_delayed already uses: the timer heap, then the port's items, then the queue state. No path takes the timer lock while it holds the other two.

What is in it

  • crates/xcl/src/hle/xgameruntime/taskqueue.rs: XTaskQueueIsEmpty counts delayed callbacks not yet due. Test is_empty_counts_delayed_callbacks_not_yet_due: a 60 s delayed callback keeps the work port non-empty and leaves the completion port empty, and termination cancels it.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on c53eed3: 859 passed, 0 failed, 42 ignored; SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • the new test without the change in XTaskQueueIsEmpty: it fails at assert!(!XTaskQueueIsEmpty(h, PORT_WORK), "a delayed callback not yet due is still queued")

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1321 (PresentX 1323)
presents per 2 s (last 3): 44 22 24
device removals: 0
crashes: 0
peak commit: 47832 MB

this PR:

xcl-smoke v1
commit: c53eed33ef1625568c739ca854e4eb34db8d1775
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1166 (PresentX 1166)
presents per 2 s (last 3): 1 0 23
device removals: 0
crashes: 0
peak commit: 49046 MB

Not tested

  • A title that waits on XTaskQueueIsEmpty with delayed callbacks pending; the smoke title's run is a regression check only.
  • The short window in which the timer thread has taken a due entry off the heap but not yet queued it still reads as empty. #1276 closes that.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 19:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1681) `emirduran707:taskqueue-is-empty-delayed` → `main` · +23 −1 · 1 files · 1 commits · open `XTaskQueueIsEmpty` looked only at a port's queued items and the callbacks in flight. A callback submitted with a delay (`XTaskQueueSubmitDelayedCallback`, or `XAsyncSchedule` with a delay) waits in the task queue's timer heap until it is due, so while it waited the port read as empty. libHttpClient's task queue, which XTaskQueue is, counts those entries. `TaskQueuePortImpl::IsEmpty` is `(m_queueList->empty()) && (m_pendingList->empty()) && (m_processingCallback == 0)`, and a delayed entry goes to `m_pendingList` ([TaskQueue.cpp](https://github.com/microsoft/libHttpClient/blob/main/Source/Task/TaskQueue.cpp)). A title that dispatches until the port is empty before it terminates a queue, or that uses `XTaskQueueIsEmpty` to tell whether its timers are done, stopped too early. The delayed callback then ran canceled at termination. `XTaskQueueIsEmpty` now also looks for the queue's entries on that port in the timer heap. The locks are taken in the order `submit_delayed` already uses: the timer heap, then the port's items, then the queue state. No path takes the timer lock while it holds the other two. **What is in it** - `crates/xcl/src/hle/xgameruntime/taskqueue.rs`: `XTaskQueueIsEmpty` counts delayed callbacks not yet due. Test `is_empty_counts_delayed_callbacks_not_yet_due`: a 60 s delayed callback keeps the work port non-empty and leaves the completion port empty, and termination cancels it. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on c53eed3: 859 passed, 0 failed, 42 ignored; SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows) - the new test without the change in `XTaskQueueIsEmpty`: it fails at `assert!(!XTaskQueueIsEmpty(h, PORT_WORK), "a delayed callback not yet due is still queued")` **Regression run** main: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1321 (PresentX 1323) presents per 2 s (last 3): 44 22 24 device removals: 0 crashes: 0 peak commit: 47832 MB ``` this PR: ``` xcl-smoke v1 commit: c53eed33ef1625568c739ca854e4eb34db8d1775 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1166 (PresentX 1166) presents per 2 s (last 3): 1 0 23 device removals: 0 crashes: 0 peak commit: 49046 MB ``` **Not tested** - A title that waits on `XTaskQueueIsEmpty` with delayed callbacks pending; the smoke title's run is a regression check only. - The short window in which the timer thread has taken a due entry off the heap but not yet queued it still reads as empty. #1276 closes that. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A delayed callback waits in the timer heap until it is due, and
XTaskQueueIsEmpty looked only at the port's items and the callbacks in
flight, so the port read as empty meanwhile. libHttpClient's
TaskQueuePortImpl::IsEmpty counts its pending list, where delayed
entries wait. Look in the timer heap too, taking the locks in the order
submit_delayed uses (timer, items, state).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:27 +00:00
Author
Owner

@⁠mantavisual on GitHub · 2026-11-24 20:46 UTC · original

Test report for c53eed33ef16 on NVIDIA, which the PR lists as not tested.

Tested

  • RTX 4060 8 GB (driver 616.92, wave32), i5-13600K, 32 GB, Windows 11 Pro 22631, Rust 1.100.0 MSVC, DXC 1.9.2602.17 (SDK 10.0.26100), debug.
  • cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 859 passed, 0 failed, 42 ignored. The new test ran.
  • Merged locally with main 4178e88: 892 passed, 0 failed, 42 ignored.
  • SKIPPED at the head: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Does the test notice a broken fix?

  • Fix reverted: fails. The port of a delayed callback ignored: fails.
  • Gap: with Arc::ptr_eq(&t.queue, &q) removed, so that delayed callbacks of any queue count, all 11 taskqueue tests still pass. The timer heap is shared by all queues and the test makes one. Creating a second queue while the callback is pending and asserting XTaskQueueIsEmpty(other, PORT_WORK) passes normally and fails with that break.

Not tested: AMD, retail title, concurrent use.

AI use: Claude Code (Claude Opus 5.5) ran this on my machine, wrote the report and posted it for me.

**@⁠mantavisual** on GitHub · 2026-11-24 20:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1681#issuecomment-7144049111) Test report for `c53eed33ef16` on NVIDIA, which the PR lists as not tested. **Tested** - RTX 4060 8 GB (driver 616.92, wave32), i5-13600K, 32 GB, Windows 11 Pro 22631, Rust 1.100.0 MSVC, DXC 1.9.2602.17 (SDK 10.0.26100), debug. - `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`: 859 passed, 0 failed, 42 ignored. The new test ran. - Merged locally with main `4178e88`: 892 passed, 0 failed, 42 ignored. - SKIPPED at the head: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). **Does the test notice a broken fix?** - Fix reverted: fails. The port of a delayed callback ignored: fails. - Gap: with `Arc::ptr_eq(&t.queue, &q)` removed, so that delayed callbacks of any queue count, all 11 `taskqueue` tests still pass. The timer heap is shared by all queues and the test makes one. Creating a second queue while the callback is pending and asserting `XTaskQueueIsEmpty(other, PORT_WORK)` passes normally and fails with that break. **Not tested:** AMD, retail title, concurrent use. **AI use:** Claude Code (Claude Opus 5.5) ran this on my machine, wrote the report and posted it for me.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 21:37 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 21:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1681#issuecomment-7145182349) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠MiharaxD on GitHub · 2026-11-24 21:44 UTC · original

Test report on an NVIDIA card, head c53eed3 (on main c160d86), which covers the "NVIDIA" line.

Tested

  • RTX 3070 Ti 8 GB (driver 621.01), Intel i5-14400F, 32 GB RAM, Windows 11 Pro 10.0.26300, Rust 1.100.0, DXC 1.9.2602.17.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 (debug) on c53eed3: 859 passed, 0 failed, 42 ignored (lib tests 810 / 0 / 22).
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64).
  • is_empty_counts_delayed_callbacks_not_yet_due passes.

Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60 (release builds, start screen, no input). main is c160d86:

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 3070 Ti
title: game
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1586)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15055 MB

this PR's head:

xcl-smoke v1
commit: c53eed33ef1625568c739ca854e4eb34db8d1775
gpu: NVIDIA GeForce RTX 3070 Ti
title: game
seconds: 60
exit: 0x0
frames shown: 1607 (PresentX 1607)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15583 MB

Not tested

  • A title that waits on XTaskQueueIsEmpty with delayed callbacks pending: the smoke run is a regression check only.
  • AMD / Intel, gameplay past the start screen.

AI use: Claude Code (Claude Opus 5.5) built the PR, ran the tests and both smoke runs, read the logs and wrote this report; I checked it before posting.

**@⁠MiharaxD** on GitHub · 2026-11-24 21:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1681#issuecomment-7145323901) Test report on an NVIDIA card, head `c53eed3` (on `main` `c160d86`), which covers the "NVIDIA" line. **Tested** - RTX 3070 Ti 8 GB (driver 621.01), Intel i5-14400F, 32 GB RAM, Windows 11 Pro 10.0.26300, Rust 1.100.0, DXC 1.9.2602.17. - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug) on `c53eed3`: **859 passed, 0 failed, 42 ignored** (lib tests 810 / 0 / 22). - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64). - `is_empty_counts_delayed_callbacks_not_yet_due` passes. **Regression run** `scripts/smoke.ps1 -Game <game folder> -Seconds 60` (release builds, start screen, no input). `main` is `c160d86`: main: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: NVIDIA GeForce RTX 3070 Ti title: game seconds: 60 exit: 0x0 frames shown: 1586 (PresentX 1586) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15055 MB ``` this PR's head: ``` xcl-smoke v1 commit: c53eed33ef1625568c739ca854e4eb34db8d1775 gpu: NVIDIA GeForce RTX 3070 Ti title: game seconds: 60 exit: 0x0 frames shown: 1607 (PresentX 1607) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15583 MB ``` **Not tested** - A title that waits on `XTaskQueueIsEmpty` with delayed callbacks pending: the smoke run is a regression check only. - AMD / Intel, gameplay past the start screen. **AI use:** Claude Code (Claude Opus 5.5) built the PR, ran the tests and both smoke runs, read the logs and wrote this report; I checked it before posting.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 03:55 UTC · original

XCL PR #1681 compatibility verification

Commit c53eed33ef1625568c739ca854e4eb34db8d1775 on STOR-WINLAB. Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. The adapter reports DoublePrecisionFloatShaderOps=0 and a wave range of 8–32. d3d12SDKLayers.dll is absent. DXC/DXIL 1.9.2609.5 and rustc 1.100.0 (0ef1bc386 2026-11-09), unoptimized builds with debug info disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run succeeded. Both emitted two deprecation warnings for Atomic::fetch_update (duplicated in the test build).
  • cargo test -p xcl xgameruntime -- --nocapture under the Arc lock reported 75 passed, 0 failed, 0 ignored, 0 SKIPPED lines. All 74 unit tests ran. The libHttpClient integration test returned early because XCL_SAMPLE_DLLS was unset. The new regression passed here and in the workspace run. In a manual queue it verified that a not-yet-due callback makes the work port nonempty, leaves the completion port empty, and clears on termination.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the Arc lock and exited 101. Across 20 harness summaries, pr1681-suite.log recorded 841 passed, 18 failed, 42 ignored and 3 SKIPPED lines. The harness totals include early returns. Two explicit skips cited no wave64 and one cited no heap windows. These skips provide no test coverage.

Of the 18 failures, 13 GPU tests reported CreateComputePipelineState returning 0x80070057. Four other GPU tests reported mismatches in fused multiply-add, implicit texture LOD, f16 lane preservation, and wave64 pixel reduction. The test-title e2e failed the D3D12.X dynamic depth-bias check (RSSetDepthBiasX), which produced a blue pixel where green was expected.

Not tested

Main-branch baseline, retail-title smoke runs, optional XCL_SAMPLE_* fixtures, and other GPU adapters.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1681-suite.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 03:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1681#issuecomment-7152364155) # XCL PR #1681 compatibility verification Commit `c53eed33ef1625568c739ca854e4eb34db8d1775` on STOR-WINLAB. Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. The adapter reports `DoublePrecisionFloatShaderOps=0` and a wave range of 8–32. `d3d12SDKLayers.dll` is absent. DXC/DXIL 1.9.2609.5 and rustc 1.100.0 (0ef1bc386 2026-11-09), unoptimized builds with debug info disabled. **Tested** - `cargo build --workspace` and `cargo test --workspace --no-run` succeeded. Both emitted two deprecation warnings for `Atomic::fetch_update` (duplicated in the test build). - `cargo test -p xcl xgameruntime -- --nocapture` under the Arc lock reported **75 passed, 0 failed, 0 ignored, 0 SKIPPED lines**. All 74 unit tests ran. The libHttpClient integration test returned early because `XCL_SAMPLE_DLLS` was unset. The new regression passed here and in the workspace run. In a manual queue it verified that a not-yet-due callback makes the work port nonempty, leaves the completion port empty, and clears on termination. - `cargo test --workspace --no-fail-fast -- --test-threads=4` ran once under the Arc lock and exited 101. Across 20 harness summaries, `pr1681-suite.log` recorded **841 passed, 18 failed, 42 ignored** and **3 SKIPPED lines**. The harness totals include early returns. Two explicit skips cited no wave64 and one cited no heap windows. These skips provide no test coverage. Of the 18 failures, 13 GPU tests reported `CreateComputePipelineState` returning `0x80070057`. Four other GPU tests reported mismatches in fused multiply-add, implicit texture LOD, f16 lane preservation, and wave64 pixel reduction. The test-title e2e failed the D3D12.X dynamic depth-bias check (`RSSetDepthBiasX`), which produced a blue pixel where green was expected. **Not tested** Main-branch baseline, retail-title smoke runs, optional `XCL_SAMPLE_*` fixtures, and other GPU adapters. **AI use** T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1681-suite.log` and published.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1681/head:github-bot/gh-1681'
git switch 'github-bot/gh-1681'

Merge

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