Tests: fine_timer_makes_short_sleeps_short takes the fastest Sleep(1), not the mean (#1487) #1628

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

@⁠upipibi on GitHub · 2026-11-24 18:24 UTC · original
upipibi:tests/coherent-virtualfree → main · +19 −7 · 1 files · 1 commits · open

Refs #1487: fine_timer_makes_short_sleeps_short, one of the failures left after #1523 (the access violation), #1600 (the XAudio2 tests) and #1590 (the VirtualFree in coherent_buffer_sanitizes_console_flags_and_state, by Bullet18x: opened first and with the cause, so this PR no longer touches it). Test-only: the change is inside #[cfg(test)].

What is in it

  • hle/kernelx.rs, fine_timer_makes_short_sleeps_short. It took the mean of 20 Sleep(1), which a busy PC (more test threads than processors) moves past 5 ms (Sleep(1) taking the 15.6 ms tick in marquezinii's report). It now checks two things:
    • the timer resolution fine_timer sets (at most 1 ms);
    • the fastest of 20 sleeps, after one that lines the thread up with the timer. With the 15.6 ms tick every one takes a tick, so a missing fine timer still fails.

Tested
NVIDIA GeForce RTX 3070, driver 616.56; Windows 11 Pro 26100 (32 logical processors); Rust 1.100.0 MSVC; debug; main 9e3831e.

  • Timer test, with 64 busy loops on the 32 processors:
    • main's test failed 4 of 5 (mean 9.2–11.6 ms);
    • a median of 21 still failed 5 of 5 (7.1–12.4 ms);
    • this version passed 10 of 10.
  • Timer test without its fine_timer() call (negative control, idle PC): fails 3 of 3, fastest sleep 14.7–15.0 ms. The resolution check alone doesn't catch that here, as other processes keep the system resolution fine.
  • The earlier head 820d235 (this change plus a VirtualFree retry, now dropped for #1590), <lib test exe> --test-threads=32, 3 runs on main without #1523: two ended with 0xc0000005, #1487's access violation, which #1523 fixes. The third gave 727 passed, 0 failed, 21 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Regression run

From eizispark's run (#1628), thanks (AMD RX 9070 XT; this PR's diff is test-only, so it shows only that nothing else changed):

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1671 (PresentX 1671)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14861 MB

PR:

xcl-smoke v1
commit: d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1680 (PresentX 1680)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14859 MB

Not tested

  • Wine. On AMD: eizispark's RX 9070 XT run passes (776 passed, 0 failed), fine_timer_makes_short_sleeps_short included.

AI use

  • Claude Code (Claude Opus 5.5) measured it, wrote the change and ran the tests.

🤖 Generated with Claude Code

**@⁠upipibi** on GitHub · 2026-11-24 18:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1628) `upipibi:tests/coherent-virtualfree` → `main` · +19 −7 · 1 files · 1 commits · open Refs #1487: `fine_timer_makes_short_sleeps_short`, one of the failures left after #1523 (the access violation), #1600 (the XAudio2 tests) and #1590 (the `VirtualFree` in `coherent_buffer_sanitizes_console_flags_and_state`, by Bullet18x: opened first and with the cause, so this PR no longer touches it). Test-only: the change is inside `#[cfg(test)]`. **What is in it** - `hle/kernelx.rs`, `fine_timer_makes_short_sleeps_short`. It took the mean of 20 `Sleep(1)`, which a busy PC (more test threads than processors) moves past 5 ms (`Sleep(1)` taking the 15.6 ms tick in marquezinii's report). It now checks two things: - the timer resolution `fine_timer` sets (at most 1 ms); - the fastest of 20 sleeps, after one that lines the thread up with the timer. With the 15.6 ms tick every one takes a tick, so a missing fine timer still fails. **Tested** NVIDIA GeForce RTX 3070, driver 616.56; Windows 11 Pro 26100 (32 logical processors); Rust 1.100.0 MSVC; debug; `main` `9e3831e`. - Timer test, with 64 busy loops on the 32 processors: - `main`'s test failed 4 of 5 (mean 9.2–11.6 ms); - a median of 21 still failed 5 of 5 (7.1–12.4 ms); - this version passed 10 of 10. - Timer test without its `fine_timer()` call (negative control, idle PC): fails 3 of 3, fastest sleep 14.7–15.0 ms. The resolution check alone doesn't catch that here, as other processes keep the system resolution fine. - The earlier head `820d235` (this change plus a `VirtualFree` retry, now dropped for #1590), `<lib test exe> --test-threads=32`, 3 runs on `main` without #1523: two ended with `0xc0000005`, #1487's access violation, which #1523 fixes. The third gave 727 passed, 0 failed, 21 ignored. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. **Regression run** From eizispark's run (https://git.gtahub.st/github/xcl-dev--xcl/pulls/1628), thanks (AMD RX 9070 XT; this PR's diff is test-only, so it shows only that nothing else changed): main: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: AMD Radeon RX 9070 XT title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1671 (PresentX 1671) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14861 MB ``` PR: ``` xcl-smoke v1 commit: d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae gpu: AMD Radeon RX 9070 XT title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1680 (PresentX 1680) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14859 MB ``` **Not tested** - Wine. On AMD: eizispark's RX 9070 XT run passes (776 passed, 0 failed), `fine_timer_makes_short_sleeps_short` included. **AI use** - Claude Code (Claude Opus 5.5) measured it, wrote the change and ran the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The test took the mean of 20 Sleep(1)s, which a busy PC (more test
threads than processors, a parallel run) moves past 5 ms (#1487). It
now checks the timer resolution fine_timer sets, and the fastest of 20
sleeps after one that lines the thread up with the timer: with the
15.6 ms tick every one takes a tick, so a missing fine timer still
fails.

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

@⁠pickles976 on GitHub · 2026-11-24 18:26 UTC · original

Approve — both are the right shape of flake fix, which is rarer than flake fixing itself. The timer test moved from "every sample < 5 ms" to "the fastest sample < 5 ms": that asserts the invariant the test actually exists for (the 15.6 ms tick was escaped; the fine timer is live) without pretending a busy CI runner schedules anything instantly — the threshold stays 3× below the tick it rules out, so the discrimination is untouched, only the optimism. The VirtualFree retry pairs the two halves correctly too: bound the wait (<2 s) and keep the error message carrying the elapsed time, so a future machine where this legitimately exceeds 2 s produces a measurement in the failure text, not just "timeout". Two small notes: ① if the retry loop exits by budget exhaustion, the assert message should distinguish "failed for 2 s" from "failed once" (the elapsed timer already in the string does this if the loop is structured to fall through — worth one glance); ② test-only is verified from the diff itself, not just the description — everything added sits inside #[cfg(test)], so zero production surface, matching the #1487 lane rules. LGTM from the side that reviews CI flakes as a tax on every other PR in the queue.

**@⁠pickles976** on GitHub · 2026-11-24 18:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1628#issuecomment-7140647014) Approve — both are the right **shape** of flake fix, which is rarer than flake fixing itself. The timer test moved from "every sample < 5 ms" to "the **fastest** sample < 5 ms": that asserts the invariant the test actually exists for (the 15.6 ms tick was escaped; the fine timer is live) without pretending a busy CI runner schedules anything instantly — the threshold stays 3× below the tick it rules out, so the discrimination is untouched, only the optimism. The VirtualFree retry pairs the two halves correctly too: bound the wait (<2 s) **and** keep the error message carrying the elapsed time, so a future machine where this legitimately exceeds 2 s produces a measurement in the failure text, not just "timeout". Two small notes: ① if the retry loop exits by budget exhaustion, the assert message should distinguish "failed for 2 s" from "failed once" (the elapsed timer already in the string does this if the loop is structured to fall through — worth one glance); ② test-only is verified from the diff itself, not just the description — everything added sits inside `#[cfg(test)]`, so zero production surface, matching the #1487 lane rules. LGTM from the side that reviews CI flakes as a tax on every other PR in the queue.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 18:37 UTC · original

Thanks for the review. One change since: I dropped the VirtualFree retry from this PR. #1590 (Bullet18x) fixes the same failure, was opened earlier and has the cause (late_release::hold keeps the buffer while another test's queue has work). So your note ① now applies to #1590's loop. This PR is the fine_timer_makes_short_sleeps_short change only (d8f9224).

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠upipibi** on GitHub · 2026-11-24 18:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1628#issuecomment-7140907461) Thanks for the review. One change since: I dropped the `VirtualFree` retry from this PR. #1590 (Bullet18x) fixes the same failure, was opened earlier and has the cause (`late_release::hold` keeps the buffer while another test's queue has work). So your note ① now applies to #1590's loop. This PR is the `fine_timer_makes_short_sleeps_short` change only (`d8f9224`). AI use: Claude Code (Claude Opus 5.5) wrote this.
Author
Owner

@⁠eizispark on GitHub · 2026-11-24 18:54 UTC · original

Hardware test report — commit d8f9224

Verified d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae (clean merge with main c160d86ef2efe3a07e4dfb473e4fa72eafb413c0): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 776 passed, 0 failed, 41 ignored (1 skipped: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)
  • hle::kernelx::tests::fine_timer_makes_short_sleeps_short passed; both wave64 GPU tests skipped on NVIDIA (gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware, plus console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) ran natively and passed on RDNA4

Regression run
main (c160d86ef2efe3a07e4dfb473e4fa72eafb413c0):

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1671 (PresentX 1671)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14861 MB

PR (d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae):

xcl-smoke v1
commit: d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1680 (PresentX 1680)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14859 MB

Not tested

  • heavily oversubscribed hosts where every Sleep(1) sample stalls past 5 ms, NVIDIA/Intel GPUs, Wine/vkd3d-proton, gameplay past the menus

AI use

  • Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).
**@⁠eizispark** on GitHub · 2026-11-24 18:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1628#issuecomment-7141326041) ### Hardware test report — commit `d8f9224` Verified `d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae` (clean merge with `main` `c160d86ef2efe3a07e4dfb473e4fa72eafb413c0`): **pass**. **Tested** - Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver `32.0.32015.16001`), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, debug tests + release smoke - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `776 passed, 0 failed, 41 ignored` (`1 skipped`: `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`) - `hle::kernelx::tests::fine_timer_makes_short_sleeps_short` passed; both wave64 GPU tests skipped on NVIDIA (`gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`, plus `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back`) ran natively and passed on RDNA4 **Regression run** `main` (`c160d86ef2efe3a07e4dfb473e4fa72eafb413c0`): ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1671 (PresentX 1671) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14861 MB ``` PR (`d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae`): ``` xcl-smoke v1 commit: d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1680 (PresentX 1680) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14859 MB ``` **Not tested** - heavily oversubscribed hosts where every `Sleep(1)` sample stalls past 5 ms, NVIDIA/Intel GPUs, Wine/vkd3d-proton, gameplay past the menus **AI use** - Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 20:46 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 20:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1628#issuecomment-7144042333) 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

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

PR #1628 verification

Head d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae in a clean detached worktree. The sole change is the timer test in crates/xcl/src/hle/kernelx.rs.

STOR-WINLAB ran Windows x64 build 26200.9974 on an AMD Ryzen 7 3800X with an Intel Arc A770 (driver 32.0.101.9175). DXC reported 1.9.2609.5. Rust was 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), using unoptimized dev/test profiles with debug info and incremental compilation disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the Arc lock. The second command built 19 test executables.
  • cargo test -p xcl --lib fine_timer_makes_short_sleeps_short -- --test-threads=1 with XCL_ADAPTER=NONE_CPU_ONLY passed 5/5 outside the Arc lock (0 failed, 0 ignored, 0 explicit skips).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once through Invoke-ArcTest.ps1 with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1. The log confirms Arc A770 selection. Cargo exited 101. All 20 result lines (19 binaries and one doctest target) sum to 760 passed, 16 failed, and 41 ignored, with six explicit skip lines.
  • The changed test passed in all six invocations. It verified a successful timer-resolution query at or below 1 ms after fine_timer() and a minimum below 5 ms across 20 Windows Sleep(1) calls following a warm-up sleep. The focused runs logged 0.50 ms before and after fine_timer(). The workspace run logged 15.62 ms before and 0.50 ms after.

Workspace failures and skips

  • The library had 15 GPU recompiler failures. Eleven reported CreateComputePipelineState error 0x80070057. Four failed assertions involving FMA, sampled LOD, f16 VALU, or wave64 reduction.
  • The end-to-end test title failed its RSSetDepthBiasX check. The top-right pixel was blue instead of green.
  • Six lines began with SKIPPED : two required wave64, two required the D3D12 debug layer, one required tiled resources tier 2, and one required heap windows. These skips provide no coverage.

Not tested

Matched main baseline, retail-title smoke runs, other GPU vendors, and controlled scheduler saturation.

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 pr1628-suite.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 04:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1628#issuecomment-7153289163) ## PR #1628 verification Head `d8f92247f9bbea16b9ecf54fcdfc86ce05cbb4ae` in a clean detached worktree. The sole change is the timer test in `crates/xcl/src/hle/kernelx.rs`. STOR-WINLAB ran Windows x64 build 26200.9974 on an AMD Ryzen 7 3800X with an Intel Arc A770 (driver 32.0.101.9175). DXC reported 1.9.2609.5. Rust was 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), using unoptimized dev/test profiles with debug info and incremental compilation disabled. **Tested** - `cargo build --workspace` and `cargo test --workspace --no-run` both exited 0 outside the Arc lock. The second command built 19 test executables. - `cargo test -p xcl --lib fine_timer_makes_short_sleeps_short -- --test-threads=1` with `XCL_ADAPTER=NONE_CPU_ONLY` passed 5/5 outside the Arc lock (0 failed, 0 ignored, 0 explicit skips). - `cargo test --workspace --no-fail-fast -- --test-threads=4` ran once through `Invoke-ArcTest.ps1` with `XCL_ADAPTER=A770` and `RUST_TEST_NOCAPTURE=1`. The log confirms Arc A770 selection. Cargo exited 101. All 20 result lines (19 binaries and one doctest target) sum to 760 passed, 16 failed, and 41 ignored, with six explicit skip lines. - The changed test passed in all six invocations. It verified a successful timer-resolution query at or below 1 ms after `fine_timer()` and a minimum below 5 ms across 20 Windows `Sleep(1)` calls following a warm-up sleep. The focused runs logged 0.50 ms before and after `fine_timer()`. The workspace run logged 15.62 ms before and 0.50 ms after. **Workspace failures and skips** - The library had 15 GPU recompiler failures. Eleven reported `CreateComputePipelineState` error `0x80070057`. Four failed assertions involving FMA, sampled LOD, f16 VALU, or wave64 reduction. - The end-to-end test title failed its `RSSetDepthBiasX` check. The top-right pixel was blue instead of green. - Six lines began with `SKIPPED `: two required wave64, two required the D3D12 debug layer, one required tiled resources tier 2, and one required heap windows. These skips provide no coverage. **Not tested** Matched `main` baseline, retail-title smoke runs, other GPU vendors, and controlled scheduler saturation. **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 `pr1628-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/1628/head:github-bot/gh-1628'
git switch 'github-bot/gh-1628'

Merge

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