Sampling profiler: VICTORY_PROFILE=1 counts named threads' stacks, folded and top-60 files beside the log #4342
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4342
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4341"
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?
@IRennie74 on GitHub · 2026-11-30 19:05 UTC · original
IRennie74:pr/sampling-profiler→main· +1871 −825 · 39 files · 11 commits · closed without mergingWhat it changes
The stage timers in
copystatare placed by hand and say which stage is long, not which functions inside it. On a Ryzen 5 5600X with an RTX 3060 the frame was about 53 ms, about 47 ms of it set byvictory-submit, with the list translators (victory-list-{i}) taking 131-215 ms of processor time a frame over four threads (figures from the new module's documentation). This adds a statistical profiler that counts whole stacks instead. Diagnostics builds only; a plain build is unchanged.crates/victory-loader/src/sampler.rs(new): withVICTORY_PROFILE=1, a thread of its own (victory-sampler) takes each chosen threadVICTORY_PROFILE_HZtimes a second (1 to 10 000, default 1000), suspends it, reads its registers and copies its stack, resumes it, and only then unwinds the copy. Nothing allocates and no lock is taken while the thread is suspended.VICTORY_PROFILE_THREADStakes name prefixes (defaultvictory-submit,victory-list,victory-relay); the wordtitleadds every title thread. Threads are listed again every second, so later threads and later names are seen. Every 20 s and at exit the addresses are named with dbghelp (ours by the pdb, the system's by exports, the title's by module and function start) and written besideVICTORY_LOG_FILE(else<cache>/logs) asprofile-<group>.folded(folded stacks forflamegraph.plor speedscope) andprofile-top.txt(the 60 functions with the most samples of their own and the 60 with the most inside them, per group, with what the sampling cost).crash::unwind_copytakes a frame limit: the stack dump keepsMAX_FRAMES(40), the sampler 48. It is now built forany(test, feature = "diagnostics")(main gated it ondiagnosticsalone inea97b1af), because the sampler's tests are built without the feature as well.threads::title_image_attells a title thread and a title frame from ours;threads::detach_allcallssampler::finish()first, so the last files are written (waiting up to 3 s) before the other threads are ended.apps/victory/src/run.rs:diagnostics()starts the sampler with the log's directory.VICTORY_PROFILEwith a schedule (<from>,<to>,<ms>,<file>) is still the older profiler inprofile.rs, which writes addresses only; its module documentation now says that1is the new one. A value of1parses to no schedule there and starts nothing.Ported from a working branch; against current main the only conflict was the
unwind_copygate above. The testa_busy_thread_is_found_at_the_topalso now waits for its busy thread to have started before listing threads: std names a thread from inside it, and under the parallel test harness the list found it unnamed in one run of six.How it was tested
VICTORY_PROFILE=1in a diagnostics build, so frame times without it are unchanged by construction; its own cost per sample is written intoprofile-top.txtwhen it runs.cargo build --locked --profile diag -p victory --features diagnostics: builds.cargo test --locked -p victory-loader --lib: passes (83 tests), with and without--features diagnostics(86 with it; twelve runs in a row green after the test fix above). The sampler's tests cover the switches' parsing, thread grouping, folding and the top list, and sample a busy thread of the test program itself, which must be found in at least 90% of samples (skipped when dbghelp or the test's pdb is missing).cargo clippy --locked -p victory-loader --all-targets -- -D warnings, with and without--features diagnostics: clean.cargo xtask policy --staged: clean.cargo testpassed for the crates it touches: yesChecked for overlap
profiler,sampler,VICTORY_PROFILE,samplingandstack sampling. Related: #1224 (merged; made the older profiler unwind a copy of the stack, which this builds on), #4203 (open; makes the olderVICTORY_PROFILEschedule profiler available in release builds, a different profiler; it also removes theunwind_copygate incrash.rsand toucheslib.rsandrun.rs, so whichever lands second needs a small rebase), #2019 (open; also changes theunwind_copygate incrash.rs), #1575 (open; list-thread stacks for the GPU timeline,VICTORY_TIMELINE_LISTS, a separate sampler invictory-gpu). None adds this sampler.62103bfb40to56a5724f5e56a5724f5eto8c1b80d539@trustno1-coder on GitHub · 2026-12-01 18:42 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed