Repository navigation
Conversation
Under Wine every look of VICTORY_PROFILE failed before the stack was read. QueryThreadCycleTime is a stub there (dlls/kernelbase/thread.c:444: FIXME, SetLastError(ERROR_CALL_NOT_IMPLEMENTED), FALSE), and Sampler::look counted its failure as a thread that had ended (profile.rs look). Measured under Proton: 19899 looks, 19899 failed, 0 samples per thread. Where the exact counter is missing (probed once in Sampler::new), cycles_of takes a thread's kernel and user time from GetThreadTimes as cycles, so the look logic is unchanged. Wine counts that time in 10 ms ticks (its get_thread_times reads /proc/<pid>/task/<tid>/stat): a thread that runs less than a tick between two looks reads as not having run, and a look's CPU share is not capped at its weight on that path (the sums over a run stay right). Windows keeps the exact counter and the cap. Wine's exports carry no size (dlls/dbghelp/symbol.c, symt_find_symbol_at), so SymFromAddrW names an export only at its own address. A frame inside ZwWaitForSingleObject was reported as ntdll.dll+0xea80, not as a kernel wait. When the frame's own address names nothing, the function's start is asked for; on Windows that lookup adds no name. Adds a_blocked_thread_is_sampled_in_a_kernel_wait: red on the previous code (no Submit in the report), green with this change.
|
Nice one @zocram4cc, the profiler being blind under Proton (19,899 looks, 0 samples) explains a lot of the empty Linux reports. Falling back to We'll check the Windows side on our RX 9070 XT (same samples as before with |
|
I ran the same two synthetic profiler tests on native Windows before and after I compiled the unchanged profiler and its test file as an integration target because the full |
|
That covers most of the Windows check we'd promised @zocram4cc on this one: exact counter path unchanged, attribution right on native Windows. What's left on our side is the in-game capture on the RX 9070 XT, and we'll post it here. |
Under Wine every look of VICTORY_PROFILE failed before the stack was read. QueryThreadCycleTime is a stub there (dlls/kernelbase/thread.c:444: FIXME, SetLastError(ERROR_CALL_NOT_IMPLEMENTED), FALSE), and Sampler::look counted its failure as a thread that had ended (profile.rs look). Measured under Proton: 19899 looks, 19899 failed, 0 samples per thread. Where the exact counter is missing (probed once in Sampler::new), cycles_of takes a thread's kernel and user time from GetThreadTimes as cycles, so the look logic is unchanged. Wine counts that time in 10 ms ticks (its get_thread_times reads /proc/<pid>/task/<tid>/stat): a thread that runs less than a tick between two looks reads as not having run, and a look's CPU share is not capped at its weight on that path (the sums over a run stay right). Windows keeps the exact counter and the cap. Wine's exports carry no size (dlls/dbghelp/symbol.c, symt_find_symbol_at), so SymFromAddrW names an export only at its own address. A frame inside ZwWaitForSingleObject was reported as ntdll.dll+0xea80, not as a kernel wait. When the frame's own address names nothing, the function's start is asked for; on Windows that lookup adds no name. Adds a_blocked_thread_is_sampled_in_a_kernel_wait: red on the previous code (no Submit in the report), green with this change. Ported from #53 onto beta-2 (Neptune base).
|
Thanks @zocram4cc. When we moved the test line to the Neptune base, we went back over all your PRs so none of your work gets lost. As of today's beta-2 (
All of them keep you as the author. Thanks again for the Linux work, it's still in. |
Base:
win10-test.betahas noprofile.rs(checked at78ad571). The profiler came in withf85101b(fxceless) on win10-test, so this PR targets win10-test.Problem
Under Proton,
VICTORY_PROFILE=1records no samples: every look at every thread fails. Measured before the fix (see the commit message): 19,899 looks, 19,899 failed, 0 samples per thread. The red run below shows the same at test level: 904 looks per thread, 904 failed, 0.0 ms on a processor.Root cause
QueryThreadCycleTimeis a stub in Wine.dlls/kernelbase/thread.c:444(ValveSoftware/wine branchexperimental_11.0) logs a FIXME once, callsSetLastError(ERROR_CALL_NOT_IMPLEMENTED)and returns FALSE.Sampler::lookcounted that failure as a missed look and dropped it, so every look was lost.dlls/dbghelp/symbol.c,symt_find_symref_at) gives a size-less symbol the length of its type, or 1 byte, so an export names only its own address. A frame inside an exported system function came out asntdll.dll+0xea80, not as the function, so kernel waits were not recognised.Fix
Sampler::newprobesQueryThreadCycleTimeonce and keeps the result asexact.missedaccounting, same per-look cap at the thread's weight.cycles_oftakes the thread's kernel and user time fromGetThreadTimesand converts it to cycles atcycles_per_us. Wine computes that from/proc/<pid>/task/<tid>/statin clock ticks (dlls/ntdll/unix/thread.c,get_thread_times,sysconf(_SC_CLK_TCK)).Windows behaviour
Not run on Windows. From the code:
QueryThreadCycleTimesucceeds there, soexactis true:cycles_oftakes the exact branch (same call, same result as before) and the per-look cap applies as before. The stand-in code is not reached.QueryThreadCycleTimecall inSampler::new.Test
New:
profile::tests::a_blocked_thread_is_sampled_in_a_kernel_wait. A thread spins and another waits on a lock, both followed for 1 s. The spinner must be sampled and mostly running; the blocked thread must be sampled and at least 95 % waiting in the Wide role.cargo xwin build --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvcpasses (exit 0) on this branch.cargo xwin test --profile diag -p victory-gpu --features diagnostics --target x86_64-pc-windows-msvc --no-run(the profile tests' own doc uses--profile diag).experimental-11.0-20261112:proton runinprefix <victory_gpu-*.exe> --exact profile::tests::a_blocked_thread_is_sampled_in_a_kernel_wait --test-threads 1. Keep the.pdbbeside the test exe: the profiler names our own functions from it.Red (fix reverted:
profile.rsat the win10-test base, new test kept), exit 101. Legend lines omitted:red output
Green (this branch), exit 0:
The 18 s is mostly Wine's dbghelp loading the 28 MB PDB on the first lookup [deduction: the same test without the PDB beside it finished in 1.2 s].
Sample report (green;
profile::tests::the_sampler_finds_threads_and_writes_its_files,--nocapture, THREADS table as printed):The pipeline thread's kernel wait is named; before the fix that thread had no samples at all. The busy thread's innermost frame is one of our functions, which stays unnamed (see known limits).
Whole profiler module (
profile::tests,--nocapture): before, 6 passed, 4 failed, 1 ignored; with this change, 7 passed, 3 failed, 1 ignored. The four red failures are the new test and the three older tests below. Only the new test changes status.Known limits
getconf CLK_TCKis 100 here: 10 ms). A thread that runs less than one tick between two looks reads as not having run. Per-look shares are coarse; sums over a run are right.VICTORY_PROFILE_HZ=100to200(default 1000). [deduction: at 100–200 Hz a look spans about one tick]time_goes_to_the_function_that_spent_it,deep_stacks_are_cut_not_lost,the_sampler_finds_threads_and_writes_its_files. With the PDB beside the exe, none of ourprofile_test_*free functions is named in the output (they show asvictory_gpu-<hash>.exe+0x…), while closures in the same module are named. Green failures:inner 0 of …,profile_test_sleepsabsent,profile_test_spin_innerabsent from the folded stacks. Why Wine's dbghelp does not name these functions is not isolated here. They were already failing before this change, for another reason: with every look failing there were no samples to assert on (red:no Submit,missedlooks, noPIPELINE WORKERS). They are not ignored in this PR.indirect.rs(duplicate test functions andmod bench),descriptor/host.rsandpipeline/host.rscall APIs whose signatures changed or no longer exist: 42 compile errors. PR Repair indirect, overlap and depth-bounds GPU tests on win10-test #37 (open, win10-test, "Repair indirect, overlap and depth-bounds GPU tests on win10-test") changes the same test files; this PR does not depend on it. For the runs above the three test modules were gated locally with#[cfg(any())]; that gate is not in this PR, and the branch builds as is.Related
time_goes_to_the_function_that_spent_itandthe_sampler_finds_threads_and_writes_its_filespassing under Wine 11.22. This PR keeps the CPU share on theGetThreadTimesstand-in, names only a function's start, and does not change inlined names. We did not run #960. Both editprofile.rsin the sampler and the naming code, so they will likely conflict.Disclosure
AI-assisted: the investigation, the change and this description were produced with an AI coding assistant, and the builds and Proton runs above were run in that session. No game files, title data or rig settings are included; the runs execute the test binary only.