Skip to content

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

Open
upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:tests/coherent-virtualfree
Open

upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:tests/coherent-virtualfree

Conversation

@upipibi

@upipibi upipibi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

Regression run

From eizispark's run (#1628 (comment)), 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

@pickles976

Copy link
Copy Markdown

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.

…, not the mean

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 (xcl-dev#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 <noreply@anthropic.com>
@upipibi
upipibi force-pushed the tests/coherent-virtualfree branch from 820d235 to d8f9224 Compare November 24, 2026 18:37
@upipibi upipibi changed the title Tests: VirtualFree after a heap and Sleep(1) on a busy PC, two parallel-run flakes (#1487) Tests: fine_timer_makes_short_sleeps_short takes the fastest Sleep(1), not the mean (#1487) Nov 24, 2026
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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.

@eizispark

Copy link
Copy Markdown

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).

@DavidM1911

Copy link
Copy Markdown
Contributor

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!

@JJAutoCompare

Copy link
Copy Markdown

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.

@throny throny added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants