Repository navigation
fix(agc): close the poll sleep timer when its thread exits - #22067
Conversation
PollSleep created a high-resolution waitable timer per thread and never closed it. Use the per-thread timer of PreciseWait, which is released with the thread; the 200 us wait is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
kurexw
left a comment
There was a problem hiding this comment.
macOS GPU test (Apple M4, MoltenVK 1.4.2, validation layer 1.4.363.1, x86-64 build under Rosetta)
Base: upstream/main a72186d + #22056 + #22074 (both needed for the macOS build); PR head 0912308e48 merged on top. Built clean (only the known libcurl link failure, #17425).
Env per AGENTS.md: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -R 'recorder|constant_phi|masked_select|sample_bit_descriptor|pixel_ancillary|scalar_buffer|shader_mode_registers|agc_driver_f64|command_batch|awaited_slot|agc_driver_idle|detiler' -V, 3 runs each on base and PR.
- Every test has the same status on base and PR in all 3 runs; no new
VUID-errors. - Every test that creates a Vulkan instance logs
Insert instance layer "VK_LAYER_KHRONOS_validation"; none logswas not found but was requested. The tests without layer lines (agc_constant_phi,agc_masked_select,agc_command_batch_*,pixel_ancillary, ...) never touch the loader. - Same on base and PR: 11
agc_driver_f64_*tests skip (the M4 has noshaderFloat64);agc_driver_recorderfails witha kept vertex window was not mirrored(#20831); the recorder tests each log oneVUID-VkDeviceCreateInfo-sType-uniquefor a duplicatedVkPhysicalDevicePortabilitySubsetFeaturesKHRin the test's own device (#21965). - The PR adds no test; I could not exercise the thread-exit path directly on macOS, so this only shows no regression in the driver tests above (
agc_driver_idle_*,agc_command_batch_*, the recorder tests).
AI-assisted: yes
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The per-thread wait timer is now owned by a helper that closes it when the thread exits, and the 200 us wait is unchanged. Nothing blocks this; the points below are optional.
What I ran
- Exact head
0912308e48560bd83b2587927b79f955d24b4785, basemain. The diff was read from the review folder; the diff was not fetched again. - Read the changed function and its includes at the head. No build and no test run in this review.
repo_read.py search PreciseWaitThreadTimer
repo_read.py search PreciseSleepWaitableTimerWithHandle
repo_read.py cat core/libs/prx/libc/include/PreciseWait.hpp 1 70
repo_read.py cat core/libs/prx/libc/include/HostThreadLocal.hpp 1 28
Results
| Check | Result | Note |
|---|---|---|
| Diff read | passed | One file, three new lines |
| Changed code read | passed | WaitMemory.cpp lines 1–40 |
| Helpers read at head | passed | PreciseWait.hpp, HostThreadLocal.hpp |
| Build | not run | Windows-only code; no builds in this review |
Author's ctest runs |
not run | Author-reported, not repeated here |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/WaitMemory.cpp:25— On Windows,PreciseWaitThreadTimer()throwsstd::runtime_errorifFlsAllocorFlsSetValuefails (HostThreadLocal.hpp, lines 13–18). The old code never threw there; it fell back to a plain sleep. Those failures are not expected, so this is a behaviour difference to know about, not a defect shown by the code.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/WaitMemory.cpp:25— No test checks that the timer handle is released. The description says none of the listed tests counts handles. A test for this is optional.
Sources
- WaitMemory.cpp, changed function
- PreciseWait.hpp, sleep helper and thread timer
- HostThreadLocal.hpp, per-thread storage
Not verified
- The Windows build and the
ctestruns (15/15, and the validation-layer logs) are author-reported. They were not run here. - That the FLS callback closes the timer when the thread exits relies on Windows behaviour that was not tested here.
- Lines 41 to 440 of
WaitMemory.cppare unchanged and were not read. - Non-Windows builds: unchanged by reading the
#elsebranch only.
To get this to a good state
Nothing is required.
Reviewed — changes requestedEight findings can break correctness or security. The main problems are stale cache reuse, stale reads after a pending write, and guest-triggered crashes in output writes. Fix these before merging. What I ran
Results
FindingsBlocking
Non-blocking
Not verified
To get this to a good stateFix the eight blocking findings first. Bump the guarded generation and the pending serial at the sites named above. Restore the guest-copy writes in the font, network, and user-service exports. Restore the name-size check, convert the GCN table descriptors, and honor the atomic-barrier switch for non-LDS updates. Then rerun the full test suite on a host that allows the seccomp filter and one that denies it. Run one device case without formatless multisample writes. After that, add the debt fragments, set |
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
What
On Windows
PollSleepcreated a high-resolution waitable timer in athread_localhandle that nothing closed, so every thread that polled kept one timer handle until process exit. It now sleeps throughPreciseSleepWaitableTimerWithHandle(PreciseWaitThreadTimer(), ...), whose per-thread timer is closed when the thread exits; the 200 us wait is unchanged and the other platforms are untouched. This is a resource-lifetime fix; no failure was observed.Tested
Windows 11, MinGW (GCC, Release), NVIDIA GeForce RTX 4070 Laptop GPU, no title.
ctest -R '^agc_driver_(queue_zero|store_idle|idle_store|wait_|submit_progress|flip|eop_interrupts)'passed (15/15). These tests run the changed wait and none of them counts handles, so none fails onmain.Validation layer: the same tests on
main(be4613d) and on this branch withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1throughctest -V(Khronos validation layer 1.4.363.1): every log showsInsert instance layer "VK_LAYER_KHRONOS_validation", none reportswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither run logs aVUID-error.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code