WIP: fix(profiling): the Windows all-thread sampler stamps each sample with its own time under HOS_CHAIN #1044
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1044
Loading…
Reference in a new issue
No description provided.
Delete branch "Amateurwizrd/Longshot:fix/windows-sampler-at"
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?
Type: fix · Risk: low · Tested on: Windows 11, RTX 5070 Ti · Needs: none
Why
On Windows,
scripts/chain.py's frame critical path, read together with an all-thread sample of the same run(
HOS_CHAIN+HOS_SAMPLE_ALL), reports the game's job threads as mostly "waiting below the game" (a host wait thepath does not see) while they are on the path. Those waits are not there: the Windows sampler gives every sample of a
sweep the one millisecond the sweep started at, so chain.py lays samples 0.6-3 ms away from stretches of the path that
last 50-100 µs. Anyone hunting the renderer's share of a Windows frame with these tools is sent after time that does
not exist. The Linux sampler (
host/posix/prof.c) has written each sample's own time since HOS_CHAIN came in(
57ed3aa8); the Windows one never did. No issue covers it (#383, the sampler's unguarded stack walk, isanother bug).
How to reproduce
Seen on: Windows 11 26200, RTX 5070 Ti (driver 621.01), Ryzen 7 7800X3D
Settings and switches:
HOS_OUTPUT_RES=640x360 HOS_DYNRES=0 HOS_FPS_MAX=1000 RX_VK_FRAMEGEN=0, plusHOS_PROFILE=5 HOS_SAMPLE_ALL=<run>/all.txt HOS_CHAIN=<run>/chain.txtwith both.gofiles present for 5-8 sSteps: Hyrule Field (child), the camera turning at full speed (right stick held right); then
python -I scripts/chain.py <run>/chain.txt <run>/all.txtExpected: "samples on the path" shows the threads on the path working, as on Linux
Actual: on main, 26-85 % of each thread's samples on the path are "waiting" (main thread 26 %, the job workers
59-86 %)
What changed
With
HOS_CHAINset, the Windows all-thread sampler writes# at <ns>before each sample, the time its thread wasstopped, which
scripts/chain.pyalready reads. The same linehost/posix/prof.cwrites on Linux.sample_all_thread()inhost/mkw_glue.ctakeshos_now_ns()afterGetThreadContext()and writes itbefore the sample's line. Without
HOS_CHAINnothing changes.Measurements
Verdict: the chain's samples now land on the path: "waiting below the game" on the path falls from 26-86 % to
0-1.5 % per thread; the path itself reads the same (8.61 and 8.80 ms a frame, two runs of different length).
Hardware: Windows 11 26200, RTX 5070 Ti 16 GB (driver 621.01), Ryzen 7 7800X3D, 32 GB
Scene: Hyrule Field (child, night), camera turning at full speed; 640x360 output, Resolution 100 %, no frame
generation, uncapped
Method: one
HOS_CHAIN+HOS_SAMPLE_ALLrun on each side (8 s on main, 5 s here: main's 8 s run filled the chain's2,097,152-record cap),
python -I scripts/chain.py chain.txt all.txt 25, the "samples on the path" block. Acorrectness check of a diagnostic, not a speed measurement.
How to reproduce: as in How to reproduce above, on each build
cefce0d165923babThe base build was main @
cefce0d1; this branch is on main @6fb13fe5. Nothing between them touches the sampler orscripts/chain.py(git diff cefce0d1 6fb13fe5 -- host/mkw_glue.c scripts/chain.pyis empty).Flags and settings
None: the line is written only under the existing
HOS_CHAIN.Testing
Tested: the run above in the game on Windows (RTX 5070 Ti); its
all.txtholds 107,732# atlines and chain.pyreads them. Game-free checks that read
host/mkw_glue.cor the profiling scripts pass: test_commit_limit,test_crash_record, test_input_background, test_intel_compiler_gate, test_warm_bounded, test_hle_stats, test_chain,
test_prof_clock, test_prof_sampling, test_prof_symbols.
python -I -B tests/run_all.py(Windows, llvm-mingw): 583passed, 26 failed, 50 skipped. 25 of the failures fail on main @
6fb13fe5too: test_auto_handheld,test_bug_report_defaults, test_crash_dialog, test_crt_options, test_fastfp_fma, test_fpx_sticky,
test_fsr_uniform_ownership, test_gpu_hang_watch, test_guest_imported, test_import_reach, test_linux_preflight,
test_make_game_cache, test_missing_nup, test_pads_after_menu, test_parallel_init_order, test_pending_guest_import,
test_portable_builder_home, test_portable_builder_startup, test_profile_stream, test_replay_write_order,
test_run_all_changed, test_spawn_emit, test_tested_configurations, test_vk_occlusion_queries, test_walk_key. The 26th,
test_longshot_ctl, does not read the diff: it failed in the full run and once alone, then passed alone (and on main).
Not tested: Linux: the changed function is in the Windows half of
host/mkw_glue.c; Linux useshost/posix/prof.c, unchanged.Must be tested: None.
Risks
What could break: an all-thread sample with
HOS_CHAINon grows by one short line a sample. Nothing else runs it.Turning it off: revert the commit.
Checklist
Everyone
type(scope): description) of the status line's type.main(not rebased: merges clean into main @bbe421f5).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.Tested in game: Windows 11, RTX 5070 Ti: Hyrule Field at 640x360 with HOS_CHAIN + HOS_SAMPLE_ALL; chain.py's samples on the path read 0-1.5 % waiting (main: 26-86 %)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.