profile: sample Wine threads without QueryThreadCycleTime #53
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/PastiiJay--klbf-lab!53
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-53"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zocram4cc on GitHub · 2026-11-25 23:31 UTC · original
zocram4cc:up/profile-wine→win10-test· +119 −20 · 2 files · 1 commits · openBase:
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.d006c10). The test modules ofindirect.rs(duplicate test functions andmod bench),descriptor/host.rsandpipeline/host.rscall APIs whose signatures changed or no longer exist: 42 compile errors. PR #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.
@PastiiJay on GitHub · 2026-11-25 23:34 UTC · original
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
GetThreadTimesonly whenQueryThreadCycleTimeis a stub keeps Windows on the exact path, which is what we want.We'll check the Windows side on our RX 9070 XT (same samples as before with
VICTORY_PROFILE=1) and report here, since that's the one part you couldn't run.@HandshakeHackin on GitHub · 2026-11-26 02:50 UTC · original
I ran the same two synthetic profiler tests on native Windows before and after
d973b9d. Both passed on based006c10and on the PR (4/4 executions). The runner returned a nonzeroQueryThreadCycleTimevalue. The tests distinguished spinning work from a thread blocked on a lock, and attributed CPU time, sleeps and waits to the expected call sites. Windows comparisonI compiled the unchanged profiler and its test file as an integration target because the full
win10-testunit target still hits the unrelated descriptor test errors tracked in #37. This covers the native counter and attribution on a hosted Windows CPU. An in-game RX 9070 XT capture is still a separate check.@PastiiJay on GitHub · 2026-11-26 02:50 UTC · original
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.