Repository navigation
feat(agc): write the worker sampler's stacks as collapsed stacks - #4570
Conversation
|
Capture from a title run: Sword of the Sea (PPSA25344), main menu, RTX 5070 Laptop (NVIDIA 616.92), Windows 11 26200, 150 s. The build is this PR's commit on our lab branch (with #4526), which carries the local patches the title still needs. Our lab branch also had an older local version of this sampler, which was reverted for this build.
The sampler output itself is not attached because it comes from a title run. AI-assisted: yes (Claude Code) |
|
Preparing a007 Windows diagnostic cross-test of7628167beb7d2b05f1c4300d157c03149b0f70b1. Applied cleanly on our current integration, source-only308d7a09d02380489422b5c6df7ff40527d846c7: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-worker-stacks-cross-test . Conventions pass. Will freshly build stack-walk plus relevant Windows unwind/exception tests before staging. Current game is still on older9e54939c9 graphics with sampling OFF; no runtime verification claim for4570 yet. The earlier copying hot samples lacked reliable callers, so DWARF walks should help distinguish costs. Profiles/title data stay local; public results will be aggregate native hot-path metadata. AI-assisted: Codex. |
|
Windows diagnostic preparation completed on head 4a4fc98: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-dispatch-provenance-cross-test . Carries credited #4570 (canonical 7628167) on the #4586 integration, plus opt-in failure-only dispatch provenance. Original Vulkan argument address/CPU reason and failed indirect command argument address/initiator/queue/opcode are reported; validation unchanged. Fresh focused checks: 8/8 passed in 17.50 s (stack walk, Windows exceptions, guest handler/raise/unwind module info, oversized GPU dispatch, indirect argument ordering, WRITE_DATA ordering), no skips. Final driver-trace follow-up: 3/3 GPU dispatch checks passed in 1.25 s. The oversized fixture emitted direct-input provenance and still rejected the invalid dimensions. Conventions pass. exception_runtime_tests is not an available target in this Windows configuration and is not included in the count. Patched graphics SHA256 0044167482FC6932E575001A44E2E40B7557D4F8AA55270C13531918AB56AF82; patched libc 7540B4D811D1F1EB5C534A3DD29109319042B0DA592A0F15D114CF83F34D74F1. Preparing a sampled diagnostic007 repeat with 12 GiB import budget; not a quiet FPS comparison. Current title runs and raw profiles remain local; no runtime stack-walk result yet. AI-assisted: Codex. |
|
Conflicts with |
APS5_SAMPLE_WORKER=<file> now also writes <file stem>.collapsed.txt: one "frame;...;frame count" line per distinct stack of queue worker 0, root first, frames as module+0xRVA, which speedscope.app and flamegraph.pl open. Walks go up to 64 frames, and nothing allocates while the worker is suspended. The libraries are built with -fno-asynchronous-unwind-tables, so most of their functions have no .pdata entry, only a DWARF record in .ehfram, and a walk ended at the first such frame. The worker's walk now steps those frames through their record, with the CIE/FDE decoding and the call frame instructions of libc's unwinder, which move from Unwind.cpp into its header unchanged. A module is indexed after the worker resumes, the first time a walk meets it, and every register the step restores is read inside the worker's stack. The process sampler (APS5_SAMPLE_THREADS) keeps its 12 frames through .pdata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7628167 to
428963d
Compare
|
Rebased onto |
Step 2 of #4477. The worker sampler (
APS5_SAMPLE_WORKER) also writes the queue worker's whole stacks as collapsed stacks, which speedscope.app and flamegraph.pl open as a flame graph. Its walk now gets through the libraries' DWARF-only frames, so most stacks reach the thread's root. The perf template that asks for a trace and a flame graph is a follow-up.What
<file>, every 20 s and at exit, the sampler writes<file stem>.collapsed.txt: oneframe;...;frame countline per distinct stack of queue worker 0, root first, each frame asmodule+0xRVA. A walk that ends before the thread's root starts with[truncated].#lines hold the sample count, the walk depth, the truncated walks, the mean and longest time the worker was suspended, and each module's name, size and PE timestamp (no paths), so a file can be checked against the binary it is symbolized with. The file is replaced through a temporary file, so a reader never sees a partial one.<file>keeps its format.-fno-asynchronous-unwind-tables, so most of their functions have no.pdataentry, only a DWARF record in.ehfram.RtlLookupFunctionEntryfinds nothing there, and the walk ended at the first such frame. The worker's walk now steps such a frame through its record: CFA rule, return address and the saved registers. A leaf without either kind of record takes its return address fromrspif that address has unwind data..ehframis indexed after the worker resumes. Walks go up to 64 frames. The process sampler (APS5_SAMPLE_THREADS) keeps its 12 frames through.pdataonly.DecodeRange) and the call frame instruction interpreter (Instructions) are libc's, used by its_Unwind_*functions. They move unchanged fromUnwind.cppintoexceptions/Unwind.hppas inline functions. The sampler doesn't call libc'sStep, becauseStepindexes modules lazily under a mutex and reads saved registers anywhere in memory, and neither is allowed while the worker is suspended.StackWalk.hppholds the per-module FDE index, the step and the collapsed-stack formatting, and doesn't depend on Windows.docs/dev/BUILD.md(Worker sampler, which also listsAPS5_SAMPLE_THREADS).Tested
Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release.
agc_stack_walk(new): a synthetic.eh_frame(azRCIE with a pc-relative FDE for apush rbp; mov rbp, rspprologue) and a stack array. It steps at the function's entry, after the push, and in the body through the frame pointer. A pc outside the record gives no record, a read outside the stack is refused with the registers unchanged, and MinGW's return column 32 is read (Windows; elsewhere the CIE is not indexed). It also checks the collapsed-stack text: merged stacks, root first, and[truncated]. It passes on Windows and, built alone, on Linux with GCC 13.3.ctest -E "^agc_driver|^video_out|^guest_video"): 618 of 619 pass, includingagc_stack_walk,windows_exceptions,guest_exception_handler,guest_raise_exception,guest_unwind_module_info,unwind_record_boundsandprx_thread_local_destructors.log_macrosfails as onmainon that machine. libc'sUnwind.cpp,Personality.cppandExceptionPersonality.cppalso compile without warnings on Linux (GCC 13.3, syntax check).[truncated]). Depth is 18.8 frames on average and 48 at most. The worker was suspended 102 us per sample on average. Before this change, no walk on the same menu reached the root. Details are in a comment below.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code