GPU: make frame pacing tests deterministic with a virtual clock #2877
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2877
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2877"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@alexandruiulian201-bot on GitHub · 2026-11-25 22:56 UTC · original
alexandruiulian201-bot:fix/frame-pacing-tests→main· +235 −130 · 1 files · 1 commits · openframe::tests::waits_end_on_ticks_and_count_framescan fail onwindows-latestCI runners after9c179ea:2_000us) and Windows' default 15.6 ms timer tick,sleep(wait)routinely oversleeps past the next 2 ms tick. Because9c179eaallows a wait to take an already-passed tick immediately (wait == 0), the followingtimeout_ms = 0poll returnsS_OKinstead ofTIMEOUT.< 10 mselapsed check afterstd::thread::sleep(Duration::ZERO).waits_end_on_ticks_and_count_framesandwaits_begun_together_take_different_ticksran in parallel against the same globalCLOCK/LASTstatics.Changes
Pacerstruct (static PACERat runtime) with injectablenow: Instantandsleepcallback so unit tests run deterministically on a virtual clock with isolated state (including explicit coverage of the9c179ealate zero-timeout poll).std::thread::sleepwhen the wait or timeout duration is zero, avoiding unnecessarySleep(0)timeslice yields on zero-timeout origin polls and late flip waits.ffi_entry_points_pace_with_the_global_clock) exercisingset_intervalandwaitonPACERwith scheduling-safe margins (10 s timeout / 1 us wait).Related to #2265; this approach isolates test state into per-test
Pacerinstances with a virtual clock and also avoidsSleep(0)calls on zero-duration waits.Verification
cargo test -p victory-gpu --locked frame::tests— 3 passed, 0 failed (0.00s)cargo test -p victory-gpu --features diagnostics --locked frame::tests— 3 passed, 0 failedcargo clippy -p victory-gpu --all-targets --locked -- -D warnings(default and--all-features) — 0 warningscargo test -p xtask --bin xtask --locked— 6 passed, 0 failed (asset policy: 1 files ok)AI-assisted. Synthetic tests only.
@Marvisak on GitHub · 2026-11-26 04:26 UTC · original
Automated triage for the maintainers.
Merge candidate. The frame clock in
frame.rsmoves into aPacerwith injectablenowandsleep, so unit tests use a virtual clock instead of real sleeps and shared statics;set_interval,next_tickandwaitcompute the same ticks, and the only behaviour change (no sleep for zero durations) is harmless. #2265 fixes the same flaky test differently and the two conflict; this one removes the timing dependence entirely, so only one should land.CI: passing.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 23:31 UTC · original · reviewed
Verified head
86162196cleanly merged ontoorigin/main(842b0cb7) on Windows 11 x64.Code Review
struct Pacer(const fn new()) with injectablenowandsleeppreserves the production locking,WAITS/frame counters, token writeback, and timeout semantics onstatic PACER, while also skipping redundant zero-durationthread::sleepcalls.Pacer::new()instances with a virtual clock eliminates OS scheduler jitter whileffi_entry_points_pace_with_the_global_clockstill covers the FFI entry points.Local Verification
cargo test --locked -p victory-gpu --lib frame::tests: 5 consecutive runs, 3/3 passed every run (0.00seach).cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): clean.cargo xtask policy:191 files ok.Looks clean and ready to merge.
@kotekompotek on GitHub · 2026-11-25 23:36 UTC · original · reviewed
Sound: the Pacer struct keeps the original semantics (interval restart anchored to the max handed-out tick) while making the clock injectable for deterministic tests — the per-kind last-tick array is what lets origin/vblank/flip waits not starve each other. LGTM.
@Dukestar69 on GitHub · 2026-11-26 10:09 UTC · original · approved these changes
Verified against
origin/main(63bcca4):cargo test -p victory-gpu --lib frame:: -- --test-threads=1: 3/3 passed in 0.00s (includingffi_entry_points_pace_with_the_global_clock).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly replaces real-time waits in frame pacing unit tests with a deterministic virtual clock.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@futurepro62 on GitHub · 2026-11-26 10:12 UTC · original
NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, since none of them names a GPU run. Tested exact head
8616219(on its base842b0cb).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.ffi_entry_points_pace_with_the_global_clock.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.