fix(vk): anchor program life events to the host trace #239
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!239
Loading…
Reference in a new issue
No description provided.
Delete branch "klimovich008/Longshot:codex/program-life-clock387"
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, RX 9070 XT; Linux, RTX 4090 (DuckNintendo) · Needs: Linux, any GPU: clock/frame alignment (T-3VG4)
Why
With
RX_VK_LOG_PROGRAM_LIFE=1the renderer logs when each program is made, first drawn and freed, but those times run on their own clock, so they can't be matched to the frames in aHOS_PRESENT_TRACEtrace: you can't tell which frame a slow first draw landed in. This adds one clock anchor that bridges the two. The tracker was searched (forge.py issue list); no issue covers it.How to reproduce
Seen on: any OS and GPU
Settings and switches:
RX_VK_LOG_PROGRAM_LIFE=1Steps: play a minute on main, then look for a line that relates the program-life times to the host clock in
longshot_log.txtExpected: a reference point to convert a program-life time into a host-trace time
Actual: none: the program-life
tvalues are seconds since the renderer's own start, with nothing tying them to the host clockWhat changed
Once the host is bound, the program-life log prints one anchor line: two host-clock readings bracketing one program-life clock reading. Off by default; with the switch off nothing is read.
gpu/vk/vk_programs.cpp: the anchor (host_before_ns,life_ns,host_after_ns), taken once after host binding; a call before the host is bound leaves it for later.tests/test_program_life_clock.py(new): the real function cut from the source, off/on/before-init.docs/development.md: how to convert a program-lifetto the host clock with the anchor (the 0.5 ms rounding allowance); twodocs/tested/run files.Measurements
Verdict: the anchor works (one line a run with the switch on, none off, on Windows AMD and Linux NVIDIA); no performance effect claimed: the A/B's difference comes from the control runs' stalls.
Hardware: Windows 11, RX 9070 XT, AMD 26.10.2, Ryzen 7 5700X3D, 64 GB
Scene: Hyrule Field (the standard test's save), camera turning at full speed; 1280x720 window (16:9), fixed Custom profile, no upscaler, no frame generation,
HOS_FPS_MAX=240Method: the standard test (std_test.py) with
RX_VK_LOG_PROGRAM_LIFE=1on both arms, 20 s windows, 3 alternating pairs without warm-ups; pair 3 skipped (its control's game clock was 0.946 inside the window, during a 277 ms frame), so 2 valid pairs; the median; clock lines counted in each run's log.How to reproduce: set
RX_VK_LOG_PROGRAM_LIFE=1, load the save, turn the camera;grep "program life: clock" longshot_log.txtBaseline: this PR measured as its code and test on main
839e85ff(f50a8d3d, a renderer-only pack, docs left out).839e85ff9b8287e6Flags and settings
None new. The existing
RX_VK_LOG_PROGRAM_LIFE=1stays off by default; with it on, it now also prints the anchor.Testing
Tested:
tests/test_program_life_clock.py: off, on and before host binding; fails on main (no anchor), passes here. Windows (llvm-mingw clang) and Linux (clang 21, WSL).python -I -B tests/run_all.py --jobs 4on this branch with main71b1edd8merged: 608 passed, 25 failed, 45 skipped; the same 25 fail on clean main71b1edd8on this PC (607 passed there: this PR adds one test), among themtest_vk_occlusion_queries.py,test_walk_key.pyandtest_crash_dialog.pyvk_programs.cppcompiled to an object with clang 21 and the build's Linux flags.3ebdf864): exactly one clock line right after the renderer starts, bracketing 120 ns; 17,497 program-life lines as before; none of either with the switch off; no error or validation lines; 59.1 fps median at the 60 cap. Code review: bibiburl (no defect).Not tested: matching program-life events to
HOS_PRESENT_TRACEframe intervals on a real run.Must be tested:
RX_VK_LOG_PROGRAM_LIFE=1andHOS_PRESENT_TRACE, convert a few first-draw times with the anchor and the documented 0.5 ms allowance, expecting each to fall inside a frame interval of the trace (Test Farm:@Beanstalkrequest on this PR, linux, for the one clock line and no errors; the conversion against the trace by hand: test request T-3VG4)Risks
What could break: nothing with the switch off (no clock is read); with it on, one extra log line.
Turning it off: leave
RX_VK_LOG_PROGRAM_LIFEunset (the default), or revert the commit.Compatibility: Nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.main.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.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Description only: the Flags and settings table and the source-reading test box filled in; no source change (still
1fea819e). Stays WIP.Refreshed the unchanged real-function fixture: PR
1fea819epasses off/on/pre-host cases; pinned main5b81a8a1fails the anchor check. Historical suite and earlier backport gameplay are labelled separately. Final-DLL gameplay, measurement, Linux and test requests remain open. This stays WIP.1fea819e7c8892a8de62Rebased linearly onto main
5e072fc8(Codex:9b4e2c3c,f8ee4f8a; same code), plus the run records (8892a8de). The fixture fails on main and passes here; full suite 517/9/36 with the same 9 failures as clean main. Measured: the standard test with RX_VK_LOG_PROGRAM_LIFE=1 on both arms, 2 valid pairs (pair 3 skipped for the control's clock), one clock-anchor line per PR run and none on main, no speed-up claimed. Linux: object and fixture with clang 21; the full Linux build is T-3VG4. Taking it out of WIP.WIP: fix(vk): anchor program life events to the host traceto fix(vk): anchor program life events to the host traceCorrection, description and run record only (
9b8287e6): pair 3's control was rejected on a 0.946 clock reading inside the window (during a 277 ms frame), not the 0.761 edge reading I quoted, which the acceptance does not use (Codex caught it). The accepted pairs and numbers are unchanged.543846ebinto codex/program-life-clock387Merged main
543846eb(3ebdf864, no force-push): the only conflict was docs/development.md, where main added the GPU-wait paragraph next to this PR's clock-anchor paragraph; both are kept. tests/test_program_life_clock.py and test_check_pr_description.py pass on the merge; the full suite follows.Full suite on the merge (
3ebdf864, main543846eb, Windows, llvm-mingw 20261104, --jobs 4): 533 passed, 3 failed, 36 skipped. The same 3 fail on clean main543846ebhere (532/3/36): tests/test_oot_state_tap.py, tests/test_tested_configurations.py, tests/test_walk_key.py.Code-only review of
3ebdf864ff; informational findings, with final approval left to another reviewer.No introduced correctness defect found in the clock-anchor change. The host readings bracket the same relative clock used by the life events, integer formatting preserves the timestamps, and an early call before host binding leaves initialization available for the later valid call. Logging disabled adds no clock reads.
The extracted-function fixture checks off/on/pre-host behavior, sample order, one-time logging and large integer timestamps; removing the anchor or caching the pre-host result would fail it. It does not establish alignment between the real platform clocks and the linked game's frame trace. The recorded Windows renderer-backport runs provide one anchor per run, with no speed-up claimed; Linux object compilation and the fixture are narrower evidence. The existing Linux clock/frame-alignment request T-3VG4 remains the validation gap: record an enabled run and match life events to host frame intervals using the documented bracket and 0.5 ms rounding allowance.
I read the full diff, initialization/logging call paths, clock implementation, fixture and reported runs. The other open changes to
vk_programs.cpptouch different functions; no required merge order found. No builds, tests or game runs performed in this review.Test request T-3VG4 — independent check. The card is not claimable yet (#239 is not from a collaborator and has no
testing wantedlabel), so this is not a claim and the request stays open.Linux, NVIDIA RTX 4090 24 GB, NVIDIA proprietary Vulkan driver. PR head
3ebdf864(a merge of main543846eb), built from the branch.Unit test:
tests/test_program_life_clock.py:PASS clock anchor off,PASS clock anchor on,PASS clock anchor before-init.With
RX_VK_LOG_PROGRAM_LIFE=1(saved spot, Hyrule Field, about 70 s, then the window closed):Exactly one clock line, right after the renderer starts, and it brackets a 128.8 ms window (host_before_ns and host_after_ns differ by 120 ns).
The program-life lines are as before: 17497 lines in the run, 15753
create, 924first draw, 315first dispatch, each with its serial, time, frame, kind, stages, codes and timings. No error or validation lines.Without the switch, the same run: 0 clock lines, 0 program-life lines anywhere in the log.
Both runs reached Hyrule Field and held the 60 fps cap (59.1 fps median); the switch adds logging only.
The request also says 'program-life lines as before': I did not build main to compare, but the merge with main adds no change to those lines.
Generated by opencode with deepseek-v4.1-flash-1017
71b1edd8into codex/program-life-clock387Merged main
71b1edd8(66af3067, a fast-forward, no force-push) and rewrote the description in the new template.--jobs 4): 608 passed, 25 failed, 45 skipped. The same 25 fail on clean main71b1edd8on this PC (607 passed there; this PR addstests/test_program_life_clock.py).@Beanstalk linux, any GPU: with RX_VK_LOG_PROGRAM_LIFE=1 on both sides, 60 s in Hyrule Field. On the PR side expect exactly one "vk: program life: clock" line in the log (main has none), and no crash or error lines on either side.
@klimovich008 only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.