perf(libkernel): wake guest mutex waiters on release on Windows #5429

Merged
Dripl1x merged 1 commit from upstream-pr/5429 into main 2026-10-13 23:31:24 +00:00
Dripl1x commented 2026-10-13 19:30:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-13T19:30:58Z.


What

On Windows a thread blocked on a guest mutex polled the host mutex. scePthreadMutexLock slept 1 ms between attempts, the last 0.5 ms of it in a busy wait, and scePthreadMutexTimedlock slept 0.5 ms. A released mutex reached its waiter up to 1 ms late, and an untimed waiter kept part of a processor busy. #2051 introduced the polling so that sceKernelRaiseException reaches a waiting thread.

Waiters now park and the release wakes them:

  • TimedWait gains a parking table keyed by the lock's address: 256 buckets, each a list of the threads' existing wait events. A waiter registers, tries the lock once more and then waits alertably on its event, so an exception is still delivered during the wait through the APC path of #2051, and the wait goes on afterwards.
  • scePthreadMutexUnlock and the release inside a condition wait wake one waiter of that mutex. They use only the mutex's address after unlocking it, so the thread that acquires the mutex next may destroy it at once.
  • A waiter first makes 1000 try_lock attempts, so a short critical section is handed over without a kernel wait.
  • The bucket's list lock is taken with exception delivery deferred to an APC that is drained right after, so a thread is never redirected into a handler while it holds that lock.
  • scePthreadMutexTimedlock, which pthread_mutex_timedlock calls, parks until its deadline; under APS5_COARSE_TIMED_WAITS it keeps the host try_lock_for. MutexOperations::Timedlock, which takes an absolute deadline and has no caller at present, parks in slices of 100 ms and reads the wall clock between them.
  • Other hosts are unchanged. The polling loop of TimedWait::AcquireUntil, which this change leaves unreachable, and PollSleepUntil are removed.

Related:

  • #4971 renames the helper at the three lock call sites this PR also edits in Mutex.cpp. A trial merge conflicts only on those lines; it is not a functional prerequisite. It is older and smaller, so this PR goes after it and is rebased when it merges; the checklist declares that order.
  • #4888 adds RaiseDeferral for the address-wait lock on Windows. This PR defers delivery around its own list lock through the existing wait counter and does not need it; a trial merge of the two is clean.

Tested

Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7; Ubuntu 26.04 under WSL, GCC 15.2.0. Release, BUILD_TESTING=ON, root configuration with FFMPEG_PREBUILT_DIR pointed at an already unpacked package. Head 99eaf73102ce5f9d4c530720ff76ad93a81bcdce on main 18c438b10. The raw output of main, the performance report and the traces are in this comment; they were captured at the previous head 2710e219a, which differs from this one only in how the spin loop pauses (SpinPause, defined as YieldProcessor(), instead of the compiler builtin) and in the test. The output for this head is in this comment.

The new Windows test guest_mutex_contention checks behaviour only, for error-checking and recursive mutexes: a blocked waiter of a plain and of a timed lock gets the mutex its holder releases, a timed lock of a held mutex times out and not before its deadline, four threads of 20,000 acquisitions each exclude one another, and 400 handoffs after which the waiter destroys the mutex. It asserts no latency and no processor share, so it passes on main as well.

Run with --report, the same executable measures instead: 31 handoffs of a held mutex to a blocked waiter, the processor time of a waiter blocked for 200 ms, and four threads contending for 0.3 s. Three --report runs of each build:

main this PR
Handoff, median 401 to 628 us 20 to 23 us
Handoff, 90th percentile 819 to 954 us 23 to 33 us
Handoff, slowest 963 to 1279 us 25 to 105 us
Processor use of a waiter blocked in a plain lock 4 to 35 % 0.0 %
Acquisitions per second, four contenders 445,000 to 450,000 751,000 to 793,000
Acquisitions per second, slowest contender 95,000 to 109,000 179,000 to 194,000
  • guest_mutex_contention passes 20 of 20 repeated runs. Since the review it has no timing assertion, so no run of it fails on main; what separates the two builds is the --report table above.
  • Windows: the 57 CTests built from the thread, synchronization, signal and exception test sources of libkernel and libc pass in 28.35 s. They include guest_mutex_raise_exception and guest_raise_exception, which deliver an exception to a thread blocked in a mutex lock and in a timed mutex lock, the condition-wait tests and guest_pthread_cancel_recovery with its coarse variant.
  • Linux: libkernel and libc build, and 13 mutex, condition, cancellation, rwlock, semaphore and exception tests pass in 4.01 s. The Linux lock path is unchanged.
  • Performance report: summary lines and traces of main and of this change from the same machine and scene (ps5-doom, -timedemo demo1) are in the same comment. That scene is limited by the 60 Hz present, so its frame times are equal and it shows no regression; it does not show the effect measured above.
  • The conventions checker, including the title and description, and git diff --check pass.

Not tested: a title that contends on guest mutexes, the Unity title of #2051 (PPSA29141), macOS, the full test suite. Full PR builds need a collaborator's manual Build run.

Checklist

  • Based on current main; no other open PR implements this mutex wait
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • No new third-party code or dependencies
  • Generic behaviour, not specific to one title
  • Depends on: #4971 (merge order only; see Related)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848408049 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5429). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-13T19:30:58Z. --- ### What On Windows a thread blocked on a guest mutex polled the host mutex. `scePthreadMutexLock` slept 1 ms between attempts, the last 0.5 ms of it in a busy wait, and `scePthreadMutexTimedlock` slept 0.5 ms. A released mutex reached its waiter up to 1 ms late, and an untimed waiter kept part of a processor busy. #2051 introduced the polling so that `sceKernelRaiseException` reaches a waiting thread. Waiters now park and the release wakes them: - `TimedWait` gains a parking table keyed by the lock's address: 256 buckets, each a list of the threads' existing wait events. A waiter registers, tries the lock once more and then waits alertably on its event, so an exception is still delivered during the wait through the APC path of #2051, and the wait goes on afterwards. - `scePthreadMutexUnlock` and the release inside a condition wait wake one waiter of that mutex. They use only the mutex's address after unlocking it, so the thread that acquires the mutex next may destroy it at once. - A waiter first makes 1000 `try_lock` attempts, so a short critical section is handed over without a kernel wait. - The bucket's list lock is taken with exception delivery deferred to an APC that is drained right after, so a thread is never redirected into a handler while it holds that lock. - `scePthreadMutexTimedlock`, which `pthread_mutex_timedlock` calls, parks until its deadline; under `APS5_COARSE_TIMED_WAITS` it keeps the host `try_lock_for`. `MutexOperations::Timedlock`, which takes an absolute deadline and has no caller at present, parks in slices of 100 ms and reads the wall clock between them. - Other hosts are unchanged. The polling loop of `TimedWait::AcquireUntil`, which this change leaves unreachable, and `PollSleepUntil` are removed. Related: - #4971 renames the helper at the three lock call sites this PR also edits in `Mutex.cpp`. A trial merge conflicts only on those lines; it is not a functional prerequisite. It is older and smaller, so this PR goes after it and is rebased when it merges; the checklist declares that order. - #4888 adds `RaiseDeferral` for the address-wait lock on Windows. This PR defers delivery around its own list lock through the existing wait counter and does not need it; a trial merge of the two is clean. ### Tested Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7; Ubuntu 26.04 under WSL, GCC 15.2.0. Release, `BUILD_TESTING=ON`, root configuration with `FFMPEG_PREBUILT_DIR` pointed at an already unpacked package. Head `99eaf73102ce5f9d4c530720ff76ad93a81bcdce` on `main` `18c438b10`. The raw output of `main`, the performance report and the traces are in [this comment](https://github.com/boykopovar/AnyPS5/pull/5429#issuecomment-6153578278); they were captured at the previous head `2710e219a`, which differs from this one only in how the spin loop pauses (`SpinPause`, defined as `YieldProcessor()`, instead of the compiler builtin) and in the test. The output for this head is in [this comment](https://github.com/boykopovar/AnyPS5/pull/5429#issuecomment-6157268523). The new Windows test `guest_mutex_contention` checks behaviour only, for error-checking and recursive mutexes: a blocked waiter of a plain and of a timed lock gets the mutex its holder releases, a timed lock of a held mutex times out and not before its deadline, four threads of 20,000 acquisitions each exclude one another, and 400 handoffs after which the waiter destroys the mutex. It asserts no latency and no processor share, so it passes on `main` as well. Run with `--report`, the same executable measures instead: 31 handoffs of a held mutex to a blocked waiter, the processor time of a waiter blocked for 200 ms, and four threads contending for 0.3 s. Three `--report` runs of each build: | | `main` | this PR | |---|---:|---:| | Handoff, median | 401 to 628 us | 20 to 23 us | | Handoff, 90th percentile | 819 to 954 us | 23 to 33 us | | Handoff, slowest | 963 to 1279 us | 25 to 105 us | | Processor use of a waiter blocked in a plain lock | 4 to 35 % | 0.0 % | | Acquisitions per second, four contenders | 445,000 to 450,000 | 751,000 to 793,000 | | Acquisitions per second, slowest contender | 95,000 to 109,000 | 179,000 to 194,000 | - `guest_mutex_contention` passes 20 of 20 repeated runs. Since the review it has no timing assertion, so no run of it fails on `main`; what separates the two builds is the `--report` table above. - Windows: the 57 CTests built from the thread, synchronization, signal and exception test sources of libkernel and libc pass in 28.35 s. They include `guest_mutex_raise_exception` and `guest_raise_exception`, which deliver an exception to a thread blocked in a mutex lock and in a timed mutex lock, the condition-wait tests and `guest_pthread_cancel_recovery` with its coarse variant. - Linux: libkernel and libc build, and 13 mutex, condition, cancellation, rwlock, semaphore and exception tests pass in 4.01 s. The Linux lock path is unchanged. - Performance report: summary lines and traces of `main` and of this change from the same machine and scene (ps5-doom, `-timedemo demo1`) are in the same comment. That scene is limited by the 60 Hz present, so its frame times are equal and it shows no regression; it does not show the effect measured above. - The conventions checker, including the title and description, and `git diff --check` pass. Not tested: a title that contends on guest mutexes, the Unity title of #2051 (PPSA29141), macOS, the full test suite. Full PR builds need a collaborator's manual Build run. ### Checklist - [x] Based on current `main`; no other open PR implements this mutex wait - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code or dependencies - [x] Generic behaviour, not specific to one title - [x] Depends on: #4971 (merge order only; see Related) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code)
Dripl1x commented 2026-10-13 19:34:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-13T19:34:04Z.


Evidence for head 2710e219a on main 18c438b10. Local build paths are replaced with <build>.

Component measurements

guest_mutex_contention_tests --report, three runs of each build of the same test source. Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7, Release.

main: the four production files from 18c438b10
errorcheck lock: handoff median 401.4 us, p90 950.7 us, max 991.0 us; a waiter blocked for 200 ms used 35.0 % of one processor
errorcheck timed lock: handoff median 542.5 us, p90 886.4 us, max 1034.5 us; a waiter blocked for 200 ms used 1.0 % of one processor
errorcheck: four contenders made 445396 acquisitions per second, the slowest 100677 per second
recursive lock: handoff median 493.0 us, p90 821.3 us, max 963.1 us; a waiter blocked for 200 ms used 6.8 % of one processor
recursive timed lock: handoff median 461.0 us, p90 842.5 us, max 994.1 us; a waiter blocked for 200 ms used 1.1 % of one processor
recursive: four contenders made 446701 acquisitions per second, the slowest 95385 per second
errorcheck lock: handoff median 513.9 us, p90 916.4 us, max 1052.3 us; a waiter blocked for 200 ms used 12.3 % of one processor
errorcheck timed lock: handoff median 537.2 us, p90 918.2 us, max 1279.4 us; a waiter blocked for 200 ms used 1.1 % of one processor
errorcheck: four contenders made 450252 acquisitions per second, the slowest 105673 per second
recursive lock: handoff median 443.1 us, p90 882.9 us, max 1035.8 us; a waiter blocked for 200 ms used 9.7 % of one processor
recursive timed lock: handoff median 462.8 us, p90 818.5 us, max 1011.3 us; a waiter blocked for 200 ms used 0.9 % of one processor
recursive: four contenders made 448082 acquisitions per second, the slowest 109020 per second
errorcheck lock: handoff median 627.7 us, p90 953.9 us, max 1097.4 us; a waiter blocked for 200 ms used 12.9 % of one processor
errorcheck timed lock: handoff median 534.5 us, p90 940.9 us, max 1008.3 us; a waiter blocked for 200 ms used 1.2 % of one processor
errorcheck: four contenders made 447197 acquisitions per second, the slowest 103761 per second
recursive lock: handoff median 504.9 us, p90 924.2 us, max 1060.5 us; a waiter blocked for 200 ms used 4.1 % of one processor
recursive timed lock: handoff median 469.8 us, p90 929.0 us, max 1037.0 us; a waiter blocked for 200 ms used 1.1 % of one processor
recursive: four contenders made 444887 acquisitions per second, the slowest 102734 per second
This PR
errorcheck lock: handoff median 21.4 us, p90 26.0 us, max 28.3 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck timed lock: handoff median 22.6 us, p90 25.8 us, max 31.9 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck: four contenders made 773767 acquisitions per second, the slowest 191615 per second
recursive lock: handoff median 21.1 us, p90 24.7 us, max 27.9 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive timed lock: handoff median 24.5 us, p90 28.2 us, max 32.9 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive: four contenders made 738953 acquisitions per second, the slowest 181190 per second
errorcheck lock: handoff median 22.3 us, p90 26.6 us, max 36.7 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck timed lock: handoff median 22.2 us, p90 24.9 us, max 31.1 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck: four contenders made 787403 acquisitions per second, the slowest 193964 per second
recursive lock: handoff median 24.0 us, p90 33.5 us, max 34.0 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive timed lock: handoff median 24.6 us, p90 31.6 us, max 219.5 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive: four contenders made 762403 acquisitions per second, the slowest 187360 per second
errorcheck lock: handoff median 21.0 us, p90 26.8 us, max 70.0 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck timed lock: handoff median 21.9 us, p90 25.4 us, max 28.5 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck: four contenders made 792442 acquisitions per second, the slowest 195714 per second
recursive lock: handoff median 22.1 us, p90 27.4 us, max 54.5 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive timed lock: handoff median 22.8 us, p90 31.0 us, max 33.1 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive: four contenders made 763382 acquisitions per second, the slowest 188680 per second

Negative control: with the four production files from main the test fails 5 of 5 runs; the first:

Test project <build>
    Start 973: guest_mutex_contention
1/1 Test #973: guest_mutex_contention ...........Exit code 0xc0000409***Exception:   1.06 sec
[time] scheduler tick raised to 0.5 ms (was 0.50 ms, now 0.50 ms, timed waits fine)
[src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0
[src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0
[src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0
[src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0

With the change it passes 20 of 20 runs (ctest --repeat until-fail:20).

Performance report

Captured as the Performance report form describes.

Title and scene: PPSA99666 (ps5-doom v1.1.1 homebrew), -timedemo demo1, presents 600 to 1499 (APS5_TRACE_FRAMES=600:900), 1920x1080.

What changed: nothing measurable in this scene. All four captures are limited by the 60 Hz present, and this homebrew has no contended guest mutex in its frame, so the captures show no regression and do not show the effect measured above. I have no title that contends on guest mutexes to capture.

Build Commit p50 ms p90 ms p99 ms max ms Trace
main 18c438b1092b 16.684 16.996 17.218 17.737 aps5-trace-18c438b1092b-29052.json.gz
this PR 2710e219a2e1 16.677 16.974 17.21 17.859 aps5-trace-2710e219a2e1-36900.json.gz
this PR 2710e219a2e1 16.682 16.999 17.208 17.545 aps5-trace-2710e219a2e1-23180.json.gz
main 18c438b1092b 16.68 16.974 17.153 17.364 aps5-trace-18c438b1092b-27724.json.gz

Both builds are clean checkouts (dirty false), each with its own complete set of libraries. NVIDIA GeForce RTX 3070 Laptop GPU, driver 617.42. The traces and the summary lines are in Dripl1x/AnyPS5@237574c7d.

Summary lines (capture order: main, this PR, this PR, main):

{"commit":"18c438b1092b","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15015.309},"presents":900,"frame_ms":{"p50":16.684,"p90":16.996,"p99":17.218,"max":17.737},"gpu_busy_ms_per_present":3.774,"worker_busy_pct":{"queue worker 0x0":98.405},"top_phases_ms_per_frame":{"Driver.Packet":16.410,"Driver.Packet.rendering_wait":16.094,"Driver.Present":2.808,"Vulkan.Retire":1.729,"Driver.Present.render_fence_wait":1.728,"Vulkan.Retire.wait":1.721,"Driver.Present.present_display_buffer":0.848,"Vulkan.Present":0.844},"trace_dropped":false,"trace":"aps5-trace-18c438b1092b-29052.json.gz"}
{"commit":"2710e219a2e1","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15014.954},"presents":900,"frame_ms":{"p50":16.677,"p90":16.974,"p99":17.210,"max":17.859},"gpu_busy_ms_per_present":3.689,"worker_busy_pct":{"queue worker 0x0":98.610},"top_phases_ms_per_frame":{"Driver.Packet":16.444,"Driver.Packet.rendering_wait":16.150,"Driver.Present":2.736,"Vulkan.Retire":1.724,"Driver.Present.render_fence_wait":1.724,"Vulkan.Retire.wait":1.715,"Driver.Present.present_display_buffer":0.806,"Vulkan.Present":0.802},"trace_dropped":false,"trace":"aps5-trace-2710e219a2e1-36900.json.gz"}
{"commit":"2710e219a2e1","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15015.150},"presents":900,"frame_ms":{"p50":16.682,"p90":16.999,"p99":17.208,"max":17.545},"gpu_busy_ms_per_present":3.748,"worker_busy_pct":{"queue worker 0x0":98.566},"top_phases_ms_per_frame":{"Driver.Packet":16.437,"Driver.Packet.rendering_wait":16.124,"Driver.Present":2.796,"Vulkan.Retire":1.741,"Driver.Present.render_fence_wait":1.740,"Vulkan.Retire.wait":1.732,"Driver.Present.present_display_buffer":0.838,"Vulkan.Present":0.834},"trace_dropped":false,"trace":"aps5-trace-2710e219a2e1-23180.json.gz"}
{"commit":"18c438b1092b","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15014.682},"presents":900,"frame_ms":{"p50":16.680,"p90":16.974,"p99":17.153,"max":17.364},"gpu_busy_ms_per_present":3.792,"worker_busy_pct":{"queue worker 0x0":98.244},"top_phases_ms_per_frame":{"Driver.Packet":16.381,"Driver.Packet.rendering_wait":16.061,"Driver.Present":2.773,"Vulkan.Retire":1.750,"Driver.Present.render_fence_wait":1.749,"Vulkan.Retire.wait":1.741,"Driver.Present.present_display_buffer":0.818,"Vulkan.Present":0.814},"trace_dropped":false,"trace":"aps5-trace-18c438b1092b-27724.json.gz"}

Capture:

  • The caches were warm: each build ran the scene once before its captures, and the title was restarted for every capture.
  • No other APS5_TRACE_* or APS5_PROFILE_* switch was set, and the log was not redirected (the title ran in its own console window).
  • The captures come from the same machine, scene and settings, in one session.
Digest: main, first capture

frames 600:900 from present 600: 900 presents, frame p50 16.7 / p90 17.0 / p99 17.2 / max 17.7 ms, GPU busy 3.8 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 18c438b109, dropped: no

{"commit":"18c438b1092b","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15015.309},"presents":900,"frame_ms":{"p50":16.684,"p90":16.996,"p99":17.218,"max":17.737},"gpu_busy_ms_per_present":3.774,"worker_busy_pct":{"queue worker 0x0":98.405},"top_phases_ms_per_frame":{"Driver.Packet":16.41,"Driver.Packet.rendering_wait":16.094,"Driver.Present":2.808,"Vulkan.Retire":1.729,"Driver.Present.render_fence_wait":1.728,"Vulkan.Retire.wait":1.721,"Driver.Present.present_display_buffer":0.848,"Vulkan.Present":0.844},"trace_dropped":false,"trace":"aps5-trace-18c438b1092b-29052.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 894: 17.7 ms at 4905 ms: Driver.Packet (queue worker 0x0) 17.7, Driver.Packet.rendering_wait (queue worker 0x0) 17.4, batch (gpu) 3.7, Driver.Present (presenter) 2.7
  • present 1272: 17.5 ms at 11211 ms: Driver.Packet (queue worker 0x0) 16.2, Driver.Packet.rendering_wait (queue worker 0x0) 15.9, batch (gpu) 3.8, Driver.Present (presenter) 2.8
  • present 761: 17.4 ms at 2686 ms: Driver.Packet (queue worker 0x0) 17.4, Driver.Packet.rendering_wait (queue worker 0x0) 17.1, batch (gpu) 3.7, Driver.Present (presenter) 2.7
  • present 951: 17.4 ms at 5856 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 17.0, batch (gpu) 3.7, Driver.Present (presenter) 2.8
  • present 1429: 17.3 ms at 13831 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 16.9, batch (gpu) 3.9, Driver.Present (presenter) 2.8

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 0.3 (2 %) 16.3 (98 %) 0.1 0.1 Driver.Packet 16.4, Driver.Completion 0.0
presenter 1.1 (6 %) 1.7 (10 %) 13.9 0.1 Driver.Present 2.8
gpu 3.8 (23 %) 0.0 (0 %) 12.9 0.0 batch 3.8

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 16.4, Driver.Packet.rendering_wait 16.1, batch 3.8, Driver.Present 2.8, Driver.Present.render_fence_wait 1.7, Vulkan.Retire 1.7

Longest waits

  • Driver.Packet.rendering_wait (queue worker 0x0) 19.6 ms at 170 ms, present 610
  • Driver.Packet.rendering_wait (queue worker 0x0) 18.6 ms at 14201 ms, present 1451
  • Driver.Packet.rendering_wait (queue worker 0x0) 18.3 ms at 12199 ms, present 1331
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.5 ms at 4908 ms, present 894
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.5 ms at 8195 ms, present 1091
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.4 ms at 5859 ms, present 951
Digest: this PR, first capture

frames 600:900 from present 600: 900 presents, frame p50 16.7 / p90 17.0 / p99 17.2 / max 17.9 ms, GPU busy 3.7 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 2710e219a2e1, dropped: no

{"commit":"2710e219a2e1","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15014.954},"presents":900,"frame_ms":{"p50":16.677,"p90":16.974,"p99":17.21,"max":17.859},"gpu_busy_ms_per_present":3.689,"worker_busy_pct":{"queue worker 0x0":98.61},"top_phases_ms_per_frame":{"Driver.Packet":16.444,"Driver.Packet.rendering_wait":16.15,"Driver.Present":2.736,"Vulkan.Retire":1.724,"Driver.Present.render_fence_wait":1.724,"Vulkan.Retire.wait":1.715,"Driver.Present.present_display_buffer":0.806,"Vulkan.Present":0.802},"trace_dropped":false,"trace":"aps5-trace-2710e219a2e1-36900.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1139: 17.9 ms at 8992 ms: Driver.Packet (queue worker 0x0) 17.8, Driver.Packet.rendering_wait (queue worker 0x0) 17.5, batch (gpu) 3.7, Driver.Present (presenter) 2.7
  • present 1169: 17.6 ms at 9493 ms: Driver.Packet (queue worker 0x0) 17.5, Driver.Packet.rendering_wait (queue worker 0x0) 17.2, batch (gpu) 3.6, Driver.Present (presenter) 2.7
  • present 839: 17.5 ms at 3987 ms: Driver.Packet (queue worker 0x0) 16.7, Driver.Packet.rendering_wait (queue worker 0x0) 16.5, batch (gpu) 3.7, Driver.Present (presenter) 2.6
  • present 822: 17.4 ms at 3704 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 17.1, batch (gpu) 3.7, Driver.Present (presenter) 2.7
  • present 1185: 17.4 ms at 9760 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 17.0, batch (gpu) 3.7, Driver.Present (presenter) 2.8

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 0.3 (2 %) 16.3 (98 %) 0.1 0.1 Driver.Packet 16.4, Driver.Completion 0.0
presenter 1.0 (6 %) 1.7 (10 %) 13.9 0.1 Driver.Present 2.7
gpu 3.7 (22 %) 0.0 (0 %) 13.0 0.0 batch 3.7

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 16.4, Driver.Packet.rendering_wait 16.2, batch 3.7, Driver.Present 2.7, Driver.Present.render_fence_wait 1.7, Vulkan.Retire 1.7

Longest waits

  • Driver.Packet.rendering_wait (queue worker 0x0) 18.2 ms at 6861 ms, present 1011
  • Driver.Packet.rendering_wait (queue worker 0x0) 18.1 ms at 2856 ms, present 771
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.5 ms at 8995 ms, present 1139
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.2 ms at 9496 ms, present 1169
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.1 ms at 10864 ms, present 1251
  • Driver.Packet.rendering_wait (queue worker 0x0) 17.0 ms at 3707 ms, present 822

Tests

Windows: 57 thread, synchronization, signal and exception CTests
Test project <build>
      Start  67: precise_wait
 1/57 Test  #67: precise_wait ...........................   Passed    0.02 sec
      Start  77: guest_execute_once
 2/57 Test  #77: guest_execute_once .....................   Passed    0.02 sec
      Start  78: guest_std_execute_once
 3/57 Test  #78: guest_std_execute_once .................   Passed    0.03 sec
      Start  79: guest_libc_threads
 4/57 Test  #79: guest_libc_threads .....................   Passed    0.05 sec
      Start  90: guest_lifecycle
 5/57 Test  #90: guest_lifecycle ........................   Passed    0.02 sec
      Start  91: guest_thread_callback_abi
 6/57 Test  #91: guest_thread_callback_abi ..............   Passed    0.02 sec
      Start 127: guest_libc_mutex_init_with_name
 7/57 Test #127: guest_libc_mutex_init_with_name ........   Passed    0.03 sec
      Start 128: guest_libc_cnd_timed_wait
 8/57 Test #128: guest_libc_cnd_timed_wait ..............   Passed    0.15 sec
      Start 151: windows_exceptions
 9/57 Test #151: windows_exceptions .....................   Passed    0.23 sec
      Start 666: guest_ampr_markers
10/57 Test #666: guest_ampr_markers .....................   Passed    0.05 sec
      Start 668: guest_ampr_threads
11/57 Test #668: guest_ampr_threads .....................   Passed    0.37 sec
      Start 669: guest_ampr_cpp_error
12/57 Test #669: guest_ampr_cpp_error ...................   Passed    0.03 sec
      Start 854: guest_posix_sem_init
13/57 Test #854: guest_posix_sem_init ...................   Passed    0.03 sec
      Start 855: guest_posix_sem_post
14/57 Test #855: guest_posix_sem_post ...................   Passed    0.03 sec
      Start 871: guest_kernel_sync
15/57 Test #871: guest_kernel_sync ......................   Passed    0.05 sec
      Start 875: guest_once
16/57 Test #875: guest_once .............................   Passed    0.03 sec
      Start 876: guest_pthread_barrier
17/57 Test #876: guest_pthread_barrier ..................   Passed    0.07 sec
      Start 880: guest_thread_self
18/57 Test #880: guest_thread_self ......................   Passed    0.03 sec
      Start 881: guest_pthread_spin
19/57 Test #881: guest_pthread_spin .....................   Passed    0.06 sec
      Start 882: guest_pthread_getname
20/57 Test #882: guest_pthread_getname ..................   Passed    0.03 sec
      Start 883: guest_pthread_attr
21/57 Test #883: guest_pthread_attr .....................   Passed    0.03 sec
      Start 884: guest_pthread_schedparam
22/57 Test #884: guest_pthread_schedparam ...............   Passed    0.03 sec
      Start 885: guest_pthread_mutexattr
23/57 Test #885: guest_pthread_mutexattr ................   Passed    0.03 sec
      Start 886: guest_pthread_mutex_errors
24/57 Test #886: guest_pthread_mutex_errors .............   Passed    0.03 sec
      Start 887: guest_pthread_start
25/57 Test #887: guest_pthread_start ....................   Passed    2.36 sec
      Start 888: guest_pthread_attr_errors
26/57 Test #888: guest_pthread_attr_errors ..............   Passed    0.04 sec
      Start 889: guest_pthread_stack
27/57 Test #889: guest_pthread_stack ....................   Passed    0.05 sec
      Start 890: guest_cond_timedwait
28/57 Test #890: guest_cond_timedwait ...................   Passed    0.09 sec
      Start 891: guest_cond_recursive_mutex
29/57 Test #891: guest_cond_recursive_mutex .............   Passed    0.07 sec
      Start 892: guest_cond_unowned_mutex
30/57 Test #892: guest_cond_unowned_mutex ...............   Passed    0.04 sec
      Start 896: guest_thread_cpu_clock
31/57 Test #896: guest_thread_cpu_clock .................   Passed    0.64 sec
      Start 897: guest_nanosleep
32/57 Test #897: guest_nanosleep ........................   Passed    0.19 sec
      Start 898: guest_pthread_sem
33/57 Test #898: guest_pthread_sem ......................   Passed    0.03 sec
      Start 899: guest_pthread_cancel
34/57 Test #899: guest_pthread_cancel ...................   Passed    0.31 sec
      Start 900: guest_pthread_cancel_recovery
35/57 Test #900: guest_pthread_cancel_recovery ..........   Passed    0.03 sec
      Start 901: guest_pthread_cancel_recovery_coarse
36/57 Test #901: guest_pthread_cancel_recovery_coarse ...   Passed    0.02 sec
      Start 902: guest_semaphore
37/57 Test #902: guest_semaphore ........................   Passed    0.03 sec
      Start 903: guest_pthread_rwlock
38/57 Test #903: guest_pthread_rwlock ...................   Passed    0.62 sec
      Start 904: guest_pthread_join_self
39/57 Test #904: guest_pthread_join_self ................   Passed    0.03 sec
      Start 905: guest_pthread_key
40/57 Test #905: guest_pthread_key ......................   Passed    0.02 sec
      Start 906: guest_pthread_destructor_lifetime
41/57 Test #906: guest_pthread_destructor_lifetime ......   Passed    0.04 sec
      Start 909: guest_signals
42/57 Test #909: guest_signals ..........................   Passed    1.52 sec
      Start 910: guest_sigtimedwait
43/57 Test #910: guest_sigtimedwait .....................   Passed    0.33 sec
      Start 913: guest_pthread_atfork
44/57 Test #913: guest_pthread_atfork ...................   Passed    0.03 sec
      Start 915: guest_signal_sets
45/57 Test #915: guest_signal_sets ......................   Passed    0.03 sec
      Start 917: guest_exception_handler
46/57 Test #917: guest_exception_handler ................   Passed    0.04 sec
      Start 918: guest_raise_exception
47/57 Test #918: guest_raise_exception ..................   Passed   15.59 sec
      Start 919: guest_raise_nested_sleep
48/57 Test #919: guest_raise_nested_sleep ...............   Passed    1.05 sec
      Start 921: guest_sync_on_address
49/57 Test #921: guest_sync_on_address ..................   Passed    1.14 sec
      Start 922: guest_umtx_op
50/57 Test #922: guest_umtx_op ..........................   Passed    0.86 sec
      Start 930: guest_waitpid
51/57 Test #930: guest_waitpid ..........................   Passed    0.03 sec
      Start 936: guest_equeue_events
52/57 Test #936: guest_equeue_events ....................   Passed    0.49 sec
      Start 941: guest_thread_sanitizer
53/57 Test #941: guest_thread_sanitizer .................   Passed    0.03 sec
      Start 958: guest_msync
54/57 Test #958: guest_msync ............................   Passed    0.03 sec
      Start 972: guest_mutex_raise_exception
55/57 Test #972: guest_mutex_raise_exception ............   Passed    0.09 sec
      Start 973: guest_mutex_contention
56/57 Test #973: guest_mutex_contention .................   Passed    3.61 sec
      Start 974: guest_pthread_rename
57/57 Test #974: guest_pthread_rename ...................   Passed    0.04 sec

100% tests passed, 0 tests failed out of 57

Total Test time (real) =  31.16 sec
Linux: 13 mutex, condition, cancellation, rwlock, semaphore and exception CTests
Test project <build>
      Start 843: guest_pthread_barrier
 1/13 Test #843: guest_pthread_barrier ..................   Passed    0.08 sec
      Start 848: guest_pthread_spin
 2/13 Test #848: guest_pthread_spin .....................   Passed    0.03 sec
      Start 852: guest_pthread_mutexattr
 3/13 Test #852: guest_pthread_mutexattr ................   Passed    0.01 sec
      Start 853: guest_pthread_mutex_errors
 4/13 Test #853: guest_pthread_mutex_errors .............   Passed    0.01 sec
      Start 857: guest_cond_timedwait
 5/13 Test #857: guest_cond_timedwait ...................   Passed    0.06 sec
      Start 858: guest_cond_recursive_mutex
 6/13 Test #858: guest_cond_recursive_mutex .............   Passed    0.01 sec
      Start 859: guest_cond_unowned_mutex
 7/13 Test #859: guest_cond_unowned_mutex ...............   Passed    0.01 sec
      Start 865: guest_pthread_sem
 8/13 Test #865: guest_pthread_sem ......................   Passed    0.01 sec
      Start 866: guest_pthread_cancel
 9/13 Test #866: guest_pthread_cancel ...................   Passed    0.17 sec
      Start 867: guest_pthread_cancel_recovery
10/13 Test #867: guest_pthread_cancel_recovery ..........   Passed    0.01 sec
      Start 868: guest_pthread_cancel_recovery_coarse
11/13 Test #868: guest_pthread_cancel_recovery_coarse ...   Passed    0.01 sec
      Start 870: guest_pthread_rwlock
12/13 Test #870: guest_pthread_rwlock ...................   Passed    0.57 sec
      Start 885: guest_raise_exception
13/13 Test #885: guest_raise_exception ..................   Passed    2.99 sec

100% tests passed, 0 tests failed out of 13

Total Test time (real) =   4.01 sec

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153578278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5429#issuecomment-6153578278). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-13T19:34:04Z. --- Evidence for head `2710e219a` on `main` `18c438b10`. Local build paths are replaced with `<build>`. ### Component measurements `guest_mutex_contention_tests --report`, three runs of each build of the same test source. Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7, Release. <details><summary>main: the four production files from 18c438b10</summary> ```text errorcheck lock: handoff median 401.4 us, p90 950.7 us, max 991.0 us; a waiter blocked for 200 ms used 35.0 % of one processor errorcheck timed lock: handoff median 542.5 us, p90 886.4 us, max 1034.5 us; a waiter blocked for 200 ms used 1.0 % of one processor errorcheck: four contenders made 445396 acquisitions per second, the slowest 100677 per second recursive lock: handoff median 493.0 us, p90 821.3 us, max 963.1 us; a waiter blocked for 200 ms used 6.8 % of one processor recursive timed lock: handoff median 461.0 us, p90 842.5 us, max 994.1 us; a waiter blocked for 200 ms used 1.1 % of one processor recursive: four contenders made 446701 acquisitions per second, the slowest 95385 per second errorcheck lock: handoff median 513.9 us, p90 916.4 us, max 1052.3 us; a waiter blocked for 200 ms used 12.3 % of one processor errorcheck timed lock: handoff median 537.2 us, p90 918.2 us, max 1279.4 us; a waiter blocked for 200 ms used 1.1 % of one processor errorcheck: four contenders made 450252 acquisitions per second, the slowest 105673 per second recursive lock: handoff median 443.1 us, p90 882.9 us, max 1035.8 us; a waiter blocked for 200 ms used 9.7 % of one processor recursive timed lock: handoff median 462.8 us, p90 818.5 us, max 1011.3 us; a waiter blocked for 200 ms used 0.9 % of one processor recursive: four contenders made 448082 acquisitions per second, the slowest 109020 per second errorcheck lock: handoff median 627.7 us, p90 953.9 us, max 1097.4 us; a waiter blocked for 200 ms used 12.9 % of one processor errorcheck timed lock: handoff median 534.5 us, p90 940.9 us, max 1008.3 us; a waiter blocked for 200 ms used 1.2 % of one processor errorcheck: four contenders made 447197 acquisitions per second, the slowest 103761 per second recursive lock: handoff median 504.9 us, p90 924.2 us, max 1060.5 us; a waiter blocked for 200 ms used 4.1 % of one processor recursive timed lock: handoff median 469.8 us, p90 929.0 us, max 1037.0 us; a waiter blocked for 200 ms used 1.1 % of one processor recursive: four contenders made 444887 acquisitions per second, the slowest 102734 per second ``` </details> <details><summary>This PR</summary> ```text errorcheck lock: handoff median 21.4 us, p90 26.0 us, max 28.3 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck timed lock: handoff median 22.6 us, p90 25.8 us, max 31.9 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck: four contenders made 773767 acquisitions per second, the slowest 191615 per second recursive lock: handoff median 21.1 us, p90 24.7 us, max 27.9 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive timed lock: handoff median 24.5 us, p90 28.2 us, max 32.9 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive: four contenders made 738953 acquisitions per second, the slowest 181190 per second errorcheck lock: handoff median 22.3 us, p90 26.6 us, max 36.7 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck timed lock: handoff median 22.2 us, p90 24.9 us, max 31.1 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck: four contenders made 787403 acquisitions per second, the slowest 193964 per second recursive lock: handoff median 24.0 us, p90 33.5 us, max 34.0 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive timed lock: handoff median 24.6 us, p90 31.6 us, max 219.5 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive: four contenders made 762403 acquisitions per second, the slowest 187360 per second errorcheck lock: handoff median 21.0 us, p90 26.8 us, max 70.0 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck timed lock: handoff median 21.9 us, p90 25.4 us, max 28.5 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck: four contenders made 792442 acquisitions per second, the slowest 195714 per second recursive lock: handoff median 22.1 us, p90 27.4 us, max 54.5 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive timed lock: handoff median 22.8 us, p90 31.0 us, max 33.1 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive: four contenders made 763382 acquisitions per second, the slowest 188680 per second ``` </details> Negative control: with the four production files from `main` the test fails 5 of 5 runs; the first: ```text Test project <build> Start 973: guest_mutex_contention 1/1 Test #973: guest_mutex_contention ...........Exit code 0xc0000409***Exception: 1.06 sec [time] scheduler tick raised to 0.5 ms (was 0.50 ms, now 0.50 ms, timed waits fine) [src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0 [src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0 [src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0 [src/Thread.cpp:524 RunThread] RunThread entry=0x7ff6550f1bc0 arg=00000041839ff4b0 self=0000019eb270fbd0 ``` With the change it passes 20 of 20 runs (`ctest --repeat until-fail:20`). ### Performance report Captured as the Performance report form describes. **Title and scene:** PPSA99666 ([ps5-doom](https://github.com/lowbit/ps5-doom/releases/tag/v1.1.1) v1.1.1 homebrew), `-timedemo demo1`, presents 600 to 1499 (`APS5_TRACE_FRAMES=600:900`), 1920x1080. **What changed:** nothing measurable in this scene. All four captures are limited by the 60 Hz present, and this homebrew has no contended guest mutex in its frame, so the captures show no regression and do not show the effect measured above. I have no title that contends on guest mutexes to capture. | Build | Commit | p50 ms | p90 ms | p99 ms | max ms | Trace | |---|---|---:|---:|---:|---:|---| | `main` | `18c438b1092b` | 16.684 | 16.996 | 17.218 | 17.737 | [aps5-trace-18c438b1092b-29052.json.gz](https://github.com/Dripl1x/AnyPS5/raw/237574c7d81225d98298ce5eec100d34c7b5fcc7/aps5-trace-18c438b1092b-29052.json.gz) | | this PR | `2710e219a2e1` | 16.677 | 16.974 | 17.21 | 17.859 | [aps5-trace-2710e219a2e1-36900.json.gz](https://github.com/Dripl1x/AnyPS5/raw/237574c7d81225d98298ce5eec100d34c7b5fcc7/aps5-trace-2710e219a2e1-36900.json.gz) | | this PR | `2710e219a2e1` | 16.682 | 16.999 | 17.208 | 17.545 | [aps5-trace-2710e219a2e1-23180.json.gz](https://github.com/Dripl1x/AnyPS5/raw/237574c7d81225d98298ce5eec100d34c7b5fcc7/aps5-trace-2710e219a2e1-23180.json.gz) | | `main` | `18c438b1092b` | 16.68 | 16.974 | 17.153 | 17.364 | [aps5-trace-18c438b1092b-27724.json.gz](https://github.com/Dripl1x/AnyPS5/raw/237574c7d81225d98298ce5eec100d34c7b5fcc7/aps5-trace-18c438b1092b-27724.json.gz) | Both builds are clean checkouts (`dirty` false), each with its own complete set of libraries. NVIDIA GeForce RTX 3070 Laptop GPU, driver 617.42. The traces and the summary lines are in [`Dripl1x/AnyPS5@237574c7d`](https://github.com/Dripl1x/AnyPS5/tree/237574c7d81225d98298ce5eec100d34c7b5fcc7). **Summary lines** (capture order: `main`, this PR, this PR, `main`): ```json {"commit":"18c438b1092b","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15015.309},"presents":900,"frame_ms":{"p50":16.684,"p90":16.996,"p99":17.218,"max":17.737},"gpu_busy_ms_per_present":3.774,"worker_busy_pct":{"queue worker 0x0":98.405},"top_phases_ms_per_frame":{"Driver.Packet":16.410,"Driver.Packet.rendering_wait":16.094,"Driver.Present":2.808,"Vulkan.Retire":1.729,"Driver.Present.render_fence_wait":1.728,"Vulkan.Retire.wait":1.721,"Driver.Present.present_display_buffer":0.848,"Vulkan.Present":0.844},"trace_dropped":false,"trace":"aps5-trace-18c438b1092b-29052.json.gz"} {"commit":"2710e219a2e1","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15014.954},"presents":900,"frame_ms":{"p50":16.677,"p90":16.974,"p99":17.210,"max":17.859},"gpu_busy_ms_per_present":3.689,"worker_busy_pct":{"queue worker 0x0":98.610},"top_phases_ms_per_frame":{"Driver.Packet":16.444,"Driver.Packet.rendering_wait":16.150,"Driver.Present":2.736,"Vulkan.Retire":1.724,"Driver.Present.render_fence_wait":1.724,"Vulkan.Retire.wait":1.715,"Driver.Present.present_display_buffer":0.806,"Vulkan.Present":0.802},"trace_dropped":false,"trace":"aps5-trace-2710e219a2e1-36900.json.gz"} {"commit":"2710e219a2e1","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15015.150},"presents":900,"frame_ms":{"p50":16.682,"p90":16.999,"p99":17.208,"max":17.545},"gpu_busy_ms_per_present":3.748,"worker_busy_pct":{"queue worker 0x0":98.566},"top_phases_ms_per_frame":{"Driver.Packet":16.437,"Driver.Packet.rendering_wait":16.124,"Driver.Present":2.796,"Vulkan.Retire":1.741,"Driver.Present.render_fence_wait":1.740,"Vulkan.Retire.wait":1.732,"Driver.Present.present_display_buffer":0.838,"Vulkan.Present":0.834},"trace_dropped":false,"trace":"aps5-trace-2710e219a2e1-23180.json.gz"} {"commit":"18c438b1092b","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15014.682},"presents":900,"frame_ms":{"p50":16.680,"p90":16.974,"p99":17.153,"max":17.364},"gpu_busy_ms_per_present":3.792,"worker_busy_pct":{"queue worker 0x0":98.244},"top_phases_ms_per_frame":{"Driver.Packet":16.381,"Driver.Packet.rendering_wait":16.061,"Driver.Present":2.773,"Vulkan.Retire":1.750,"Driver.Present.render_fence_wait":1.749,"Vulkan.Retire.wait":1.741,"Driver.Present.present_display_buffer":0.818,"Vulkan.Present":0.814},"trace_dropped":false,"trace":"aps5-trace-18c438b1092b-27724.json.gz"} ``` **Capture:** - The caches were warm: each build ran the scene once before its captures, and the title was restarted for every capture. - No other `APS5_TRACE_*` or `APS5_PROFILE_*` switch was set, and the log was not redirected (the title ran in its own console window). - The captures come from the same machine, scene and settings, in one session. <details><summary>Digest: main, first capture</summary> **frames 600:900** from present 600: 900 presents, frame p50 16.7 / p90 17.0 / p99 17.2 / max 17.7 ms, GPU busy 3.8 ms per present NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 18c438b1092b, dropped: no ```json {"commit":"18c438b1092b","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15015.309},"presents":900,"frame_ms":{"p50":16.684,"p90":16.996,"p99":17.218,"max":17.737},"gpu_busy_ms_per_present":3.774,"worker_busy_pct":{"queue worker 0x0":98.405},"top_phases_ms_per_frame":{"Driver.Packet":16.41,"Driver.Packet.rendering_wait":16.094,"Driver.Present":2.808,"Vulkan.Retire":1.729,"Driver.Present.render_fence_wait":1.728,"Vulkan.Retire.wait":1.721,"Driver.Present.present_display_buffer":0.848,"Vulkan.Present":0.844},"trace_dropped":false,"trace":"aps5-trace-18c438b1092b-29052.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 894: 17.7 ms at 4905 ms: Driver.Packet (queue worker 0x0) 17.7, Driver.Packet.rendering_wait (queue worker 0x0) 17.4, batch (gpu) 3.7, Driver.Present (presenter) 2.7 - present 1272: 17.5 ms at 11211 ms: Driver.Packet (queue worker 0x0) 16.2, Driver.Packet.rendering_wait (queue worker 0x0) 15.9, batch (gpu) 3.8, Driver.Present (presenter) 2.8 - present 761: 17.4 ms at 2686 ms: Driver.Packet (queue worker 0x0) 17.4, Driver.Packet.rendering_wait (queue worker 0x0) 17.1, batch (gpu) 3.7, Driver.Present (presenter) 2.7 - present 951: 17.4 ms at 5856 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 17.0, batch (gpu) 3.7, Driver.Present (presenter) 2.8 - present 1429: 17.3 ms at 13831 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 16.9, batch (gpu) 3.9, Driver.Present (presenter) 2.8 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 0.3 (2 %) | 16.3 (98 %) | 0.1 | 0.1 | Driver.Packet 16.4, Driver.Completion 0.0 | | presenter | 1.1 (6 %) | 1.7 (10 %) | 13.9 | 0.1 | Driver.Present 2.8 | | gpu | 3.8 (23 %) | 0.0 (0 %) | 12.9 | 0.0 | batch 3.8 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 16.4, Driver.Packet.rendering_wait 16.1, batch 3.8, Driver.Present 2.8, Driver.Present.render_fence_wait 1.7, Vulkan.Retire 1.7 **Longest waits** - Driver.Packet.rendering_wait (queue worker 0x0) 19.6 ms at 170 ms, present 610 - Driver.Packet.rendering_wait (queue worker 0x0) 18.6 ms at 14201 ms, present 1451 - Driver.Packet.rendering_wait (queue worker 0x0) 18.3 ms at 12199 ms, present 1331 - Driver.Packet.rendering_wait (queue worker 0x0) 17.5 ms at 4908 ms, present 894 - Driver.Packet.rendering_wait (queue worker 0x0) 17.5 ms at 8195 ms, present 1091 - Driver.Packet.rendering_wait (queue worker 0x0) 17.4 ms at 5859 ms, present 951 </details> <details><summary>Digest: this PR, first capture</summary> **frames 600:900** from present 600: 900 presents, frame p50 16.7 / p90 17.0 / p99 17.2 / max 17.9 ms, GPU busy 3.7 ms per present NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 2710e219a2e1, dropped: no ```json {"commit":"2710e219a2e1","dirty":false,"env":{"APS5_TRACE_FRAMES":"600:900"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"frames 600:900","first_present":600,"ms":15014.954},"presents":900,"frame_ms":{"p50":16.677,"p90":16.974,"p99":17.21,"max":17.859},"gpu_busy_ms_per_present":3.689,"worker_busy_pct":{"queue worker 0x0":98.61},"top_phases_ms_per_frame":{"Driver.Packet":16.444,"Driver.Packet.rendering_wait":16.15,"Driver.Present":2.736,"Vulkan.Retire":1.724,"Driver.Present.render_fence_wait":1.724,"Vulkan.Retire.wait":1.715,"Driver.Present.present_display_buffer":0.806,"Vulkan.Present":0.802},"trace_dropped":false,"trace":"aps5-trace-2710e219a2e1-36900.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1139: 17.9 ms at 8992 ms: Driver.Packet (queue worker 0x0) 17.8, Driver.Packet.rendering_wait (queue worker 0x0) 17.5, batch (gpu) 3.7, Driver.Present (presenter) 2.7 - present 1169: 17.6 ms at 9493 ms: Driver.Packet (queue worker 0x0) 17.5, Driver.Packet.rendering_wait (queue worker 0x0) 17.2, batch (gpu) 3.6, Driver.Present (presenter) 2.7 - present 839: 17.5 ms at 3987 ms: Driver.Packet (queue worker 0x0) 16.7, Driver.Packet.rendering_wait (queue worker 0x0) 16.5, batch (gpu) 3.7, Driver.Present (presenter) 2.6 - present 822: 17.4 ms at 3704 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 17.1, batch (gpu) 3.7, Driver.Present (presenter) 2.7 - present 1185: 17.4 ms at 9760 ms: Driver.Packet (queue worker 0x0) 17.3, Driver.Packet.rendering_wait (queue worker 0x0) 17.0, batch (gpu) 3.7, Driver.Present (presenter) 2.8 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 0.3 (2 %) | 16.3 (98 %) | 0.1 | 0.1 | Driver.Packet 16.4, Driver.Completion 0.0 | | presenter | 1.0 (6 %) | 1.7 (10 %) | 13.9 | 0.1 | Driver.Present 2.7 | | gpu | 3.7 (22 %) | 0.0 (0 %) | 13.0 | 0.0 | batch 3.7 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 16.4, Driver.Packet.rendering_wait 16.2, batch 3.7, Driver.Present 2.7, Driver.Present.render_fence_wait 1.7, Vulkan.Retire 1.7 **Longest waits** - Driver.Packet.rendering_wait (queue worker 0x0) 18.2 ms at 6861 ms, present 1011 - Driver.Packet.rendering_wait (queue worker 0x0) 18.1 ms at 2856 ms, present 771 - Driver.Packet.rendering_wait (queue worker 0x0) 17.5 ms at 8995 ms, present 1139 - Driver.Packet.rendering_wait (queue worker 0x0) 17.2 ms at 9496 ms, present 1169 - Driver.Packet.rendering_wait (queue worker 0x0) 17.1 ms at 10864 ms, present 1251 - Driver.Packet.rendering_wait (queue worker 0x0) 17.0 ms at 3707 ms, present 822 </details> ### Tests <details><summary>Windows: 57 thread, synchronization, signal and exception CTests</summary> ```text Test project <build> Start 67: precise_wait 1/57 Test #67: precise_wait ........................... Passed 0.02 sec Start 77: guest_execute_once 2/57 Test #77: guest_execute_once ..................... Passed 0.02 sec Start 78: guest_std_execute_once 3/57 Test #78: guest_std_execute_once ................. Passed 0.03 sec Start 79: guest_libc_threads 4/57 Test #79: guest_libc_threads ..................... Passed 0.05 sec Start 90: guest_lifecycle 5/57 Test #90: guest_lifecycle ........................ Passed 0.02 sec Start 91: guest_thread_callback_abi 6/57 Test #91: guest_thread_callback_abi .............. Passed 0.02 sec Start 127: guest_libc_mutex_init_with_name 7/57 Test #127: guest_libc_mutex_init_with_name ........ Passed 0.03 sec Start 128: guest_libc_cnd_timed_wait 8/57 Test #128: guest_libc_cnd_timed_wait .............. Passed 0.15 sec Start 151: windows_exceptions 9/57 Test #151: windows_exceptions ..................... Passed 0.23 sec Start 666: guest_ampr_markers 10/57 Test #666: guest_ampr_markers ..................... Passed 0.05 sec Start 668: guest_ampr_threads 11/57 Test #668: guest_ampr_threads ..................... Passed 0.37 sec Start 669: guest_ampr_cpp_error 12/57 Test #669: guest_ampr_cpp_error ................... Passed 0.03 sec Start 854: guest_posix_sem_init 13/57 Test #854: guest_posix_sem_init ................... Passed 0.03 sec Start 855: guest_posix_sem_post 14/57 Test #855: guest_posix_sem_post ................... Passed 0.03 sec Start 871: guest_kernel_sync 15/57 Test #871: guest_kernel_sync ...................... Passed 0.05 sec Start 875: guest_once 16/57 Test #875: guest_once ............................. Passed 0.03 sec Start 876: guest_pthread_barrier 17/57 Test #876: guest_pthread_barrier .................. Passed 0.07 sec Start 880: guest_thread_self 18/57 Test #880: guest_thread_self ...................... Passed 0.03 sec Start 881: guest_pthread_spin 19/57 Test #881: guest_pthread_spin ..................... Passed 0.06 sec Start 882: guest_pthread_getname 20/57 Test #882: guest_pthread_getname .................. Passed 0.03 sec Start 883: guest_pthread_attr 21/57 Test #883: guest_pthread_attr ..................... Passed 0.03 sec Start 884: guest_pthread_schedparam 22/57 Test #884: guest_pthread_schedparam ............... Passed 0.03 sec Start 885: guest_pthread_mutexattr 23/57 Test #885: guest_pthread_mutexattr ................ Passed 0.03 sec Start 886: guest_pthread_mutex_errors 24/57 Test #886: guest_pthread_mutex_errors ............. Passed 0.03 sec Start 887: guest_pthread_start 25/57 Test #887: guest_pthread_start .................... Passed 2.36 sec Start 888: guest_pthread_attr_errors 26/57 Test #888: guest_pthread_attr_errors .............. Passed 0.04 sec Start 889: guest_pthread_stack 27/57 Test #889: guest_pthread_stack .................... Passed 0.05 sec Start 890: guest_cond_timedwait 28/57 Test #890: guest_cond_timedwait ................... Passed 0.09 sec Start 891: guest_cond_recursive_mutex 29/57 Test #891: guest_cond_recursive_mutex ............. Passed 0.07 sec Start 892: guest_cond_unowned_mutex 30/57 Test #892: guest_cond_unowned_mutex ............... Passed 0.04 sec Start 896: guest_thread_cpu_clock 31/57 Test #896: guest_thread_cpu_clock ................. Passed 0.64 sec Start 897: guest_nanosleep 32/57 Test #897: guest_nanosleep ........................ Passed 0.19 sec Start 898: guest_pthread_sem 33/57 Test #898: guest_pthread_sem ...................... Passed 0.03 sec Start 899: guest_pthread_cancel 34/57 Test #899: guest_pthread_cancel ................... Passed 0.31 sec Start 900: guest_pthread_cancel_recovery 35/57 Test #900: guest_pthread_cancel_recovery .......... Passed 0.03 sec Start 901: guest_pthread_cancel_recovery_coarse 36/57 Test #901: guest_pthread_cancel_recovery_coarse ... Passed 0.02 sec Start 902: guest_semaphore 37/57 Test #902: guest_semaphore ........................ Passed 0.03 sec Start 903: guest_pthread_rwlock 38/57 Test #903: guest_pthread_rwlock ................... Passed 0.62 sec Start 904: guest_pthread_join_self 39/57 Test #904: guest_pthread_join_self ................ Passed 0.03 sec Start 905: guest_pthread_key 40/57 Test #905: guest_pthread_key ...................... Passed 0.02 sec Start 906: guest_pthread_destructor_lifetime 41/57 Test #906: guest_pthread_destructor_lifetime ...... Passed 0.04 sec Start 909: guest_signals 42/57 Test #909: guest_signals .......................... Passed 1.52 sec Start 910: guest_sigtimedwait 43/57 Test #910: guest_sigtimedwait ..................... Passed 0.33 sec Start 913: guest_pthread_atfork 44/57 Test #913: guest_pthread_atfork ................... Passed 0.03 sec Start 915: guest_signal_sets 45/57 Test #915: guest_signal_sets ...................... Passed 0.03 sec Start 917: guest_exception_handler 46/57 Test #917: guest_exception_handler ................ Passed 0.04 sec Start 918: guest_raise_exception 47/57 Test #918: guest_raise_exception .................. Passed 15.59 sec Start 919: guest_raise_nested_sleep 48/57 Test #919: guest_raise_nested_sleep ............... Passed 1.05 sec Start 921: guest_sync_on_address 49/57 Test #921: guest_sync_on_address .................. Passed 1.14 sec Start 922: guest_umtx_op 50/57 Test #922: guest_umtx_op .......................... Passed 0.86 sec Start 930: guest_waitpid 51/57 Test #930: guest_waitpid .......................... Passed 0.03 sec Start 936: guest_equeue_events 52/57 Test #936: guest_equeue_events .................... Passed 0.49 sec Start 941: guest_thread_sanitizer 53/57 Test #941: guest_thread_sanitizer ................. Passed 0.03 sec Start 958: guest_msync 54/57 Test #958: guest_msync ............................ Passed 0.03 sec Start 972: guest_mutex_raise_exception 55/57 Test #972: guest_mutex_raise_exception ............ Passed 0.09 sec Start 973: guest_mutex_contention 56/57 Test #973: guest_mutex_contention ................. Passed 3.61 sec Start 974: guest_pthread_rename 57/57 Test #974: guest_pthread_rename ................... Passed 0.04 sec 100% tests passed, 0 tests failed out of 57 Total Test time (real) = 31.16 sec ``` </details> <details><summary>Linux: 13 mutex, condition, cancellation, rwlock, semaphore and exception CTests</summary> ```text Test project <build> Start 843: guest_pthread_barrier 1/13 Test #843: guest_pthread_barrier .................. Passed 0.08 sec Start 848: guest_pthread_spin 2/13 Test #848: guest_pthread_spin ..................... Passed 0.03 sec Start 852: guest_pthread_mutexattr 3/13 Test #852: guest_pthread_mutexattr ................ Passed 0.01 sec Start 853: guest_pthread_mutex_errors 4/13 Test #853: guest_pthread_mutex_errors ............. Passed 0.01 sec Start 857: guest_cond_timedwait 5/13 Test #857: guest_cond_timedwait ................... Passed 0.06 sec Start 858: guest_cond_recursive_mutex 6/13 Test #858: guest_cond_recursive_mutex ............. Passed 0.01 sec Start 859: guest_cond_unowned_mutex 7/13 Test #859: guest_cond_unowned_mutex ............... Passed 0.01 sec Start 865: guest_pthread_sem 8/13 Test #865: guest_pthread_sem ...................... Passed 0.01 sec Start 866: guest_pthread_cancel 9/13 Test #866: guest_pthread_cancel ................... Passed 0.17 sec Start 867: guest_pthread_cancel_recovery 10/13 Test #867: guest_pthread_cancel_recovery .......... Passed 0.01 sec Start 868: guest_pthread_cancel_recovery_coarse 11/13 Test #868: guest_pthread_cancel_recovery_coarse ... Passed 0.01 sec Start 870: guest_pthread_rwlock 12/13 Test #870: guest_pthread_rwlock ................... Passed 0.57 sec Start 885: guest_raise_exception 13/13 Test #885: guest_raise_exception .................. Passed 2.99 sec 100% tests passed, 0 tests failed out of 13 Total Test time (real) = 4.01 sec ``` </details> AI-assisted (Claude Code).
Dripl1x commented 2026-10-13 19:34:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-13T19:34:44Z.


@xXPBSXx this PR edits the three lock call sites in Pthread/src/Mutex.cpp where #4971 (6ddb7e5c5) switches acquireMutex to acquireResolved. A trial git merge-tree conflicts only on those lines. #4971 is older and smaller, so this PR lists it in Depends on as a merge order, not a prerequisite, and I rebase after it lands: the calls become acquireResolved(current, ...), with the null check before current is used as the parking key.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153591584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5429#issuecomment-6153591584). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-13T19:34:44Z. --- @xXPBSXx this PR edits the three lock call sites in `Pthread/src/Mutex.cpp` where #4971 (`6ddb7e5c5`) switches `acquireMutex` to `acquireResolved`. A trial `git merge-tree` conflicts only on those lines. #4971 is older and smaller, so this PR lists it in `Depends on` as a merge order, not a prerequisite, and I rebase after it lands: the calls become `acquireResolved(current, ...)`, with the null check before `current` is used as the parking key. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-13 23:06:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T23:06:08Z.


Two things before this can go in:

  • TimedWait.hpp:34: please use YieldProcessor(), as TimedWait.cpp already does, instead of __builtin_ia32_pause().
  • GuestMutexContention.cpp:162-164 asserts on wall-clock latency and processor share, which will fail at random on loaded CI runners. Please keep those numbers in --report and leave the test to the checks that don't depend on timing.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157085235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5429#issuecomment-6157085235). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T23:06:08Z. --- Two things before this can go in: - `TimedWait.hpp:34`: please use `YieldProcessor()`, as `TimedWait.cpp` already does, instead of `__builtin_ia32_pause()`. - `GuestMutexContention.cpp:162-164` asserts on wall-clock latency and processor share, which will fail at random on loaded CI runners. Please keep those numbers in `--report` and leave the test to the checks that don't depend on timing.
Dripl1x commented 2026-10-13 23:20:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-13T23:20:08Z.


@oneandonlydean both are done in 99eaf7310.

  • TimedWait.hpp: the spin loop now calls TimedWait::SpinPause(), which TimedWait.cpp defines as YieldProcessor(). The header cannot name YieldProcessor itself without including <windows.h> into every file that includes it (Pthread.hpp, VideoOutDriver.hpp and AvPlayer.hpp among them), so the call sits behind a function in the file that already uses it. __builtin_ia32_pause is gone.
  • GuestMutexContention.cpp: the three assertions on latency and processor share are removed. I also removed the two other places that depended on timing: the upper bound on the 20 ms timed-lock timeout, and the fixed 0.3 s the four contenders ran for; each of them now makes 20,000 acquisitions. The measurements run only with --report.

What the test still checks: a blocked waiter of a plain and of a timed lock gets the mutex its holder releases, a timed lock of a held mutex times out and not before its deadline, the four contenders exclude one another and each finishes its acquisitions, and 400 handoffs after which the waiter destroys the mutex, for error-checking and recursive mutexes.

One consequence: without a timing assertion the test passes on main too, so the failing control the description reported no longer exists. The description says so now; what separates the two builds is the --report output.

Results at this head, same machines as before (Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7; Ubuntu 26.04 under WSL, GCC 15.2.0; Release). The DOOM traces were not captured again: the production change since 2710e219a is the pause call alone.

  • guest_mutex_contention: 20 of 20 repeated runs pass.
  • Windows: the same 57 thread, synchronization, signal and exception CTests pass.
  • Linux: the same 13 tests pass.
  • --report, three runs: handoff median 20 to 23 us, 90th percentile 23 to 33 us, slowest 25 to 105 us; a blocked waiter uses 0.0 % of a processor; four contenders make 751,000 to 793,000 acquisitions per second. The table in the description has these numbers; the main column is unchanged.
--report, three runs at 99eaf7310
errorcheck lock: handoff median 23.4 us, p90 33.3 us, max 43.9 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck timed lock: handoff median 21.2 us, p90 26.0 us, max 66.8 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck: four contenders made 781948 acquisitions per second, the slowest 193682 per second
recursive lock: handoff median 20.0 us, p90 25.6 us, max 31.0 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive timed lock: handoff median 19.8 us, p90 23.3 us, max 24.6 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive: four contenders made 774974 acquisitions per second, the slowest 179065 per second
guest mutex contention: PASS
errorcheck lock: handoff median 20.6 us, p90 25.9 us, max 37.7 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck timed lock: handoff median 20.7 us, p90 24.4 us, max 104.7 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck: four contenders made 793146 acquisitions per second, the slowest 194428 per second
recursive lock: handoff median 20.0 us, p90 24.3 us, max 39.6 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive timed lock: handoff median 20.7 us, p90 25.8 us, max 29.9 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive: four contenders made 760327 acquisitions per second, the slowest 186323 per second
guest mutex contention: PASS
errorcheck lock: handoff median 21.3 us, p90 26.4 us, max 34.0 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck timed lock: handoff median 20.2 us, p90 23.9 us, max 30.8 us; a waiter blocked for 200 ms used 0.0 % of one processor
errorcheck: four contenders made 790018 acquisitions per second, the slowest 190335 per second
recursive lock: handoff median 21.4 us, p90 28.7 us, max 31.1 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive timed lock: handoff median 21.5 us, p90 25.6 us, max 33.0 us; a waiter blocked for 200 ms used 0.0 % of one processor
recursive: four contenders made 751112 acquisitions per second, the slowest 185987 per second
guest mutex contention: PASS
guest_mutex_contention, 20 repeated runs
    Test #973: guest_mutex_contention ...........   Passed    0.64 sec
    Test #973: guest_mutex_contention ...........   Passed    0.62 sec
    Test #973: guest_mutex_contention ...........   Passed    0.64 sec
    Test #973: guest_mutex_contention ...........   Passed    0.60 sec
    Test #973: guest_mutex_contention ...........   Passed    0.60 sec
    Test #973: guest_mutex_contention ...........   Passed    0.63 sec
    Test #973: guest_mutex_contention ...........   Passed    0.62 sec
    Test #973: guest_mutex_contention ...........   Passed    0.61 sec
    Test #973: guest_mutex_contention ...........   Passed    0.62 sec
    Test #973: guest_mutex_contention ...........   Passed    0.77 sec
    Test #973: guest_mutex_contention ...........   Passed    0.64 sec
    Test #973: guest_mutex_contention ...........   Passed    0.67 sec
    Test #973: guest_mutex_contention ...........   Passed    0.68 sec
    Test #973: guest_mutex_contention ...........   Passed    0.63 sec
    Test #973: guest_mutex_contention ...........   Passed    1.04 sec
    Test #973: guest_mutex_contention ...........   Passed    0.67 sec
    Test #973: guest_mutex_contention ...........   Passed    0.68 sec
    Test #973: guest_mutex_contention ...........   Passed    0.69 sec
    Test #973: guest_mutex_contention ...........   Passed    0.67 sec
1/1 Test #973: guest_mutex_contention ...........   Passed    0.63 sec
100% tests passed, 0 tests failed out of 1
Total Test time (real) =  13.46 sec
Windows, 57 tests
Test project <build>
 1/57 Test  #67: precise_wait ...........................   Passed    0.02 sec
 2/57 Test  #77: guest_execute_once .....................   Passed    0.02 sec
 3/57 Test  #78: guest_std_execute_once .................   Passed    0.03 sec
 4/57 Test  #79: guest_libc_threads .....................   Passed    0.06 sec
 5/57 Test  #90: guest_lifecycle ........................   Passed    0.03 sec
 6/57 Test  #91: guest_thread_callback_abi ..............   Passed    0.03 sec
 7/57 Test #127: guest_libc_mutex_init_with_name ........   Passed    0.02 sec
 8/57 Test #128: guest_libc_cnd_timed_wait ..............   Passed    0.14 sec
 9/57 Test #151: windows_exceptions .....................   Passed    0.34 sec
10/57 Test #666: guest_ampr_markers .....................   Passed    0.05 sec
11/57 Test #668: guest_ampr_threads .....................   Passed    0.37 sec
12/57 Test #669: guest_ampr_cpp_error ...................   Passed    0.02 sec
13/57 Test #854: guest_posix_sem_init ...................   Passed    0.02 sec
14/57 Test #855: guest_posix_sem_post ...................   Passed    0.03 sec
15/57 Test #871: guest_kernel_sync ......................   Passed    0.05 sec
16/57 Test #875: guest_once .............................   Passed    0.03 sec
17/57 Test #876: guest_pthread_barrier ..................   Passed    0.06 sec
18/57 Test #880: guest_thread_self ......................   Passed    0.03 sec
19/57 Test #881: guest_pthread_spin .....................   Passed    0.06 sec
20/57 Test #882: guest_pthread_getname ..................   Passed    0.03 sec
21/57 Test #883: guest_pthread_attr .....................   Passed    0.03 sec
22/57 Test #884: guest_pthread_schedparam ...............   Passed    0.03 sec
23/57 Test #885: guest_pthread_mutexattr ................   Passed    0.03 sec
24/57 Test #886: guest_pthread_mutex_errors .............   Passed    0.03 sec
25/57 Test #887: guest_pthread_start ....................   Passed    2.71 sec
26/57 Test #888: guest_pthread_attr_errors ..............   Passed    0.03 sec
27/57 Test #889: guest_pthread_stack ....................   Passed    0.03 sec
28/57 Test #890: guest_cond_timedwait ...................   Passed    0.08 sec
29/57 Test #891: guest_cond_recursive_mutex .............   Passed    0.03 sec
30/57 Test #892: guest_cond_unowned_mutex ...............   Passed    0.03 sec
31/57 Test #896: guest_thread_cpu_clock .................   Passed    0.63 sec
32/57 Test #897: guest_nanosleep ........................   Passed    0.19 sec
33/57 Test #898: guest_pthread_sem ......................   Passed    0.05 sec
34/57 Test #899: guest_pthread_cancel ...................   Passed    0.31 sec
35/57 Test #900: guest_pthread_cancel_recovery ..........   Passed    0.03 sec
36/57 Test #901: guest_pthread_cancel_recovery_coarse ...   Passed    0.03 sec
37/57 Test #902: guest_semaphore ........................   Passed    0.03 sec
38/57 Test #903: guest_pthread_rwlock ...................   Passed    0.64 sec
39/57 Test #904: guest_pthread_join_self ................   Passed    0.03 sec
40/57 Test #905: guest_pthread_key ......................   Passed    0.03 sec
41/57 Test #906: guest_pthread_destructor_lifetime ......   Passed    0.04 sec
42/57 Test #909: guest_signals ..........................   Passed    1.53 sec
43/57 Test #910: guest_sigtimedwait .....................   Passed    0.31 sec
44/57 Test #913: guest_pthread_atfork ...................   Passed    0.02 sec
45/57 Test #915: guest_signal_sets ......................   Passed    0.03 sec
46/57 Test #917: guest_exception_handler ................   Passed    0.02 sec
47/57 Test #918: guest_raise_exception ..................   Passed   15.55 sec
48/57 Test #919: guest_raise_nested_sleep ...............   Passed    1.03 sec
49/57 Test #921: guest_sync_on_address ..................   Passed    1.12 sec
50/57 Test #922: guest_umtx_op ..........................   Passed    0.86 sec
51/57 Test #930: guest_waitpid ..........................   Passed    0.02 sec
52/57 Test #936: guest_equeue_events ....................   Passed    0.46 sec
53/57 Test #941: guest_thread_sanitizer .................   Passed    0.02 sec
54/57 Test #958: guest_msync ............................   Passed    0.02 sec
55/57 Test #972: guest_mutex_raise_exception ............   Passed    0.05 sec
56/57 Test #973: guest_mutex_contention .................   Passed    0.60 sec
57/57 Test #974: guest_pthread_rename ...................   Passed    0.02 sec
100% tests passed, 0 tests failed out of 57
Total Test time (real) =  28.35 sec
Linux, 13 tests
Test project <build>
 1/13 Test #843: guest_pthread_barrier ..................   Passed    0.08 sec
 2/13 Test #848: guest_pthread_spin .....................   Passed    0.03 sec
 3/13 Test #852: guest_pthread_mutexattr ................   Passed    0.01 sec
 4/13 Test #853: guest_pthread_mutex_errors .............   Passed    0.00 sec
 5/13 Test #857: guest_cond_timedwait ...................   Passed    0.06 sec
 6/13 Test #858: guest_cond_recursive_mutex .............   Passed    0.01 sec
 7/13 Test #859: guest_cond_unowned_mutex ...............   Passed    0.01 sec
 8/13 Test #865: guest_pthread_sem ......................   Passed    0.01 sec
 9/13 Test #866: guest_pthread_cancel ...................   Passed    0.17 sec
10/13 Test #867: guest_pthread_cancel_recovery ..........   Passed    0.01 sec
11/13 Test #868: guest_pthread_cancel_recovery_coarse ...   Passed    0.01 sec
12/13 Test #870: guest_pthread_rwlock ...................   Passed    0.56 sec
13/13 Test #885: guest_raise_exception ..................   Passed    3.00 sec
100% tests passed, 0 tests failed out of 13
Total Test time (real) =   4.01 sec

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157268523 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5429#issuecomment-6157268523). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-13T23:20:08Z. --- @oneandonlydean both are done in `99eaf7310`. - `TimedWait.hpp`: the spin loop now calls `TimedWait::SpinPause()`, which `TimedWait.cpp` defines as `YieldProcessor()`. The header cannot name `YieldProcessor` itself without including `<windows.h>` into every file that includes it (`Pthread.hpp`, `VideoOutDriver.hpp` and `AvPlayer.hpp` among them), so the call sits behind a function in the file that already uses it. `__builtin_ia32_pause` is gone. - `GuestMutexContention.cpp`: the three assertions on latency and processor share are removed. I also removed the two other places that depended on timing: the upper bound on the 20 ms timed-lock timeout, and the fixed 0.3 s the four contenders ran for; each of them now makes 20,000 acquisitions. The measurements run only with `--report`. What the test still checks: a blocked waiter of a plain and of a timed lock gets the mutex its holder releases, a timed lock of a held mutex times out and not before its deadline, the four contenders exclude one another and each finishes its acquisitions, and 400 handoffs after which the waiter destroys the mutex, for error-checking and recursive mutexes. One consequence: without a timing assertion the test passes on `main` too, so the failing control the description reported no longer exists. The description says so now; what separates the two builds is the `--report` output. Results at this head, same machines as before (Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7; Ubuntu 26.04 under WSL, GCC 15.2.0; Release). The DOOM traces were not captured again: the production change since `2710e219a` is the pause call alone. - `guest_mutex_contention`: 20 of 20 repeated runs pass. - Windows: the same 57 thread, synchronization, signal and exception CTests pass. - Linux: the same 13 tests pass. - `--report`, three runs: handoff median 20 to 23 us, 90th percentile 23 to 33 us, slowest 25 to 105 us; a blocked waiter uses 0.0 % of a processor; four contenders make 751,000 to 793,000 acquisitions per second. The table in the description has these numbers; the `main` column is unchanged. <details><summary>--report, three runs at 99eaf7310</summary> ```text errorcheck lock: handoff median 23.4 us, p90 33.3 us, max 43.9 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck timed lock: handoff median 21.2 us, p90 26.0 us, max 66.8 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck: four contenders made 781948 acquisitions per second, the slowest 193682 per second recursive lock: handoff median 20.0 us, p90 25.6 us, max 31.0 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive timed lock: handoff median 19.8 us, p90 23.3 us, max 24.6 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive: four contenders made 774974 acquisitions per second, the slowest 179065 per second guest mutex contention: PASS errorcheck lock: handoff median 20.6 us, p90 25.9 us, max 37.7 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck timed lock: handoff median 20.7 us, p90 24.4 us, max 104.7 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck: four contenders made 793146 acquisitions per second, the slowest 194428 per second recursive lock: handoff median 20.0 us, p90 24.3 us, max 39.6 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive timed lock: handoff median 20.7 us, p90 25.8 us, max 29.9 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive: four contenders made 760327 acquisitions per second, the slowest 186323 per second guest mutex contention: PASS errorcheck lock: handoff median 21.3 us, p90 26.4 us, max 34.0 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck timed lock: handoff median 20.2 us, p90 23.9 us, max 30.8 us; a waiter blocked for 200 ms used 0.0 % of one processor errorcheck: four contenders made 790018 acquisitions per second, the slowest 190335 per second recursive lock: handoff median 21.4 us, p90 28.7 us, max 31.1 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive timed lock: handoff median 21.5 us, p90 25.6 us, max 33.0 us; a waiter blocked for 200 ms used 0.0 % of one processor recursive: four contenders made 751112 acquisitions per second, the slowest 185987 per second guest mutex contention: PASS ``` </details> <details><summary>guest_mutex_contention, 20 repeated runs</summary> ```text Test #973: guest_mutex_contention ........... Passed 0.64 sec Test #973: guest_mutex_contention ........... Passed 0.62 sec Test #973: guest_mutex_contention ........... Passed 0.64 sec Test #973: guest_mutex_contention ........... Passed 0.60 sec Test #973: guest_mutex_contention ........... Passed 0.60 sec Test #973: guest_mutex_contention ........... Passed 0.63 sec Test #973: guest_mutex_contention ........... Passed 0.62 sec Test #973: guest_mutex_contention ........... Passed 0.61 sec Test #973: guest_mutex_contention ........... Passed 0.62 sec Test #973: guest_mutex_contention ........... Passed 0.77 sec Test #973: guest_mutex_contention ........... Passed 0.64 sec Test #973: guest_mutex_contention ........... Passed 0.67 sec Test #973: guest_mutex_contention ........... Passed 0.68 sec Test #973: guest_mutex_contention ........... Passed 0.63 sec Test #973: guest_mutex_contention ........... Passed 1.04 sec Test #973: guest_mutex_contention ........... Passed 0.67 sec Test #973: guest_mutex_contention ........... Passed 0.68 sec Test #973: guest_mutex_contention ........... Passed 0.69 sec Test #973: guest_mutex_contention ........... Passed 0.67 sec 1/1 Test #973: guest_mutex_contention ........... Passed 0.63 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 13.46 sec ``` </details> <details><summary>Windows, 57 tests</summary> ```text Test project <build> 1/57 Test #67: precise_wait ........................... Passed 0.02 sec 2/57 Test #77: guest_execute_once ..................... Passed 0.02 sec 3/57 Test #78: guest_std_execute_once ................. Passed 0.03 sec 4/57 Test #79: guest_libc_threads ..................... Passed 0.06 sec 5/57 Test #90: guest_lifecycle ........................ Passed 0.03 sec 6/57 Test #91: guest_thread_callback_abi .............. Passed 0.03 sec 7/57 Test #127: guest_libc_mutex_init_with_name ........ Passed 0.02 sec 8/57 Test #128: guest_libc_cnd_timed_wait .............. Passed 0.14 sec 9/57 Test #151: windows_exceptions ..................... Passed 0.34 sec 10/57 Test #666: guest_ampr_markers ..................... Passed 0.05 sec 11/57 Test #668: guest_ampr_threads ..................... Passed 0.37 sec 12/57 Test #669: guest_ampr_cpp_error ................... Passed 0.02 sec 13/57 Test #854: guest_posix_sem_init ................... Passed 0.02 sec 14/57 Test #855: guest_posix_sem_post ................... Passed 0.03 sec 15/57 Test #871: guest_kernel_sync ...................... Passed 0.05 sec 16/57 Test #875: guest_once ............................. Passed 0.03 sec 17/57 Test #876: guest_pthread_barrier .................. Passed 0.06 sec 18/57 Test #880: guest_thread_self ...................... Passed 0.03 sec 19/57 Test #881: guest_pthread_spin ..................... Passed 0.06 sec 20/57 Test #882: guest_pthread_getname .................. Passed 0.03 sec 21/57 Test #883: guest_pthread_attr ..................... Passed 0.03 sec 22/57 Test #884: guest_pthread_schedparam ............... Passed 0.03 sec 23/57 Test #885: guest_pthread_mutexattr ................ Passed 0.03 sec 24/57 Test #886: guest_pthread_mutex_errors ............. Passed 0.03 sec 25/57 Test #887: guest_pthread_start .................... Passed 2.71 sec 26/57 Test #888: guest_pthread_attr_errors .............. Passed 0.03 sec 27/57 Test #889: guest_pthread_stack .................... Passed 0.03 sec 28/57 Test #890: guest_cond_timedwait ................... Passed 0.08 sec 29/57 Test #891: guest_cond_recursive_mutex ............. Passed 0.03 sec 30/57 Test #892: guest_cond_unowned_mutex ............... Passed 0.03 sec 31/57 Test #896: guest_thread_cpu_clock ................. Passed 0.63 sec 32/57 Test #897: guest_nanosleep ........................ Passed 0.19 sec 33/57 Test #898: guest_pthread_sem ...................... Passed 0.05 sec 34/57 Test #899: guest_pthread_cancel ................... Passed 0.31 sec 35/57 Test #900: guest_pthread_cancel_recovery .......... Passed 0.03 sec 36/57 Test #901: guest_pthread_cancel_recovery_coarse ... Passed 0.03 sec 37/57 Test #902: guest_semaphore ........................ Passed 0.03 sec 38/57 Test #903: guest_pthread_rwlock ................... Passed 0.64 sec 39/57 Test #904: guest_pthread_join_self ................ Passed 0.03 sec 40/57 Test #905: guest_pthread_key ...................... Passed 0.03 sec 41/57 Test #906: guest_pthread_destructor_lifetime ...... Passed 0.04 sec 42/57 Test #909: guest_signals .......................... Passed 1.53 sec 43/57 Test #910: guest_sigtimedwait ..................... Passed 0.31 sec 44/57 Test #913: guest_pthread_atfork ................... Passed 0.02 sec 45/57 Test #915: guest_signal_sets ...................... Passed 0.03 sec 46/57 Test #917: guest_exception_handler ................ Passed 0.02 sec 47/57 Test #918: guest_raise_exception .................. Passed 15.55 sec 48/57 Test #919: guest_raise_nested_sleep ............... Passed 1.03 sec 49/57 Test #921: guest_sync_on_address .................. Passed 1.12 sec 50/57 Test #922: guest_umtx_op .......................... Passed 0.86 sec 51/57 Test #930: guest_waitpid .......................... Passed 0.02 sec 52/57 Test #936: guest_equeue_events .................... Passed 0.46 sec 53/57 Test #941: guest_thread_sanitizer ................. Passed 0.02 sec 54/57 Test #958: guest_msync ............................ Passed 0.02 sec 55/57 Test #972: guest_mutex_raise_exception ............ Passed 0.05 sec 56/57 Test #973: guest_mutex_contention ................. Passed 0.60 sec 57/57 Test #974: guest_pthread_rename ................... Passed 0.02 sec 100% tests passed, 0 tests failed out of 57 Total Test time (real) = 28.35 sec ``` </details> <details><summary>Linux, 13 tests</summary> ```text Test project <build> 1/13 Test #843: guest_pthread_barrier .................. Passed 0.08 sec 2/13 Test #848: guest_pthread_spin ..................... Passed 0.03 sec 3/13 Test #852: guest_pthread_mutexattr ................ Passed 0.01 sec 4/13 Test #853: guest_pthread_mutex_errors ............. Passed 0.00 sec 5/13 Test #857: guest_cond_timedwait ................... Passed 0.06 sec 6/13 Test #858: guest_cond_recursive_mutex ............. Passed 0.01 sec 7/13 Test #859: guest_cond_unowned_mutex ............... Passed 0.01 sec 8/13 Test #865: guest_pthread_sem ...................... Passed 0.01 sec 9/13 Test #866: guest_pthread_cancel ................... Passed 0.17 sec 10/13 Test #867: guest_pthread_cancel_recovery .......... Passed 0.01 sec 11/13 Test #868: guest_pthread_cancel_recovery_coarse ... Passed 0.01 sec 12/13 Test #870: guest_pthread_rwlock ................... Passed 0.56 sec 13/13 Test #885: guest_raise_exception .................. Passed 3.00 sec 100% tests passed, 0 tests failed out of 13 Total Test time (real) = 4.01 sec ``` </details> AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5429
No description provided.