fix(perf): fit perf summaries under the sender's limit, no stale or cutscene poses #1383
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1383
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:fix/perf-samples-followup"
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: medium · Tested on: Windows 11 (game-free tests only) · Needs: Linux and Windows, any GPU, an in-game run
Why
#1372's per-second samples could lose whole summaries, and could send wrong or more exact data than the docs promise. Above about 300 samples plus a few maps, a summary goes over the launcher's 60 KiB limit, and the launcher deletes it, map totals and all. After going back to the title, samples kept Link's last field position. In a cutscene the camera angles were read from the wrong object, and exact positions left the PC although the docs say only rounded cells do. This follow-up, stacked on #1372 at gab9281's request, fixes the points of the review on #1372. Merge it after #1372, or fold it into it.
See #1372.
What changed
Every summary now fits the sender's limit: the maps' totals always go, and when the samples don't fit, an even spread of them does. Samples carry cell and bin middles, not exact places. The host gives a pose only while it is current and from the gameplay camera, and reads it at most 4 times a second.
summary_json()ingpu/vk/perf_report.hfits the samples tokMaxBody(60 KiB, the same asMAX_BODYinnx2/perf_report.py, checked bytests/test_perf_report.py). It counts what the sender'sjson.dumpsadds (sent_size(): non-ASCII becomes\uescapes) and leaveskSenderRoomfor the version the sender may fill in.RX_VK_PERF_INTERVALkeeps its 60 to 840 range (840: the relay's 900 s a map); past about five minutes the samples are thinned.hos_perf_info()inhost/hos_main.cgives no pose once it is a second old (PERF_POSE_STALE_NS), and the title block clears it where it clearsmap_now.oot_perf_pose()reads yaw and pitch only when camera zero's view has the gameplay type (0x84c18a88, as the flight and free camera check). A position over 1e6 or an angle over 64 rad counts as no pose.since_sampleis gone. The sample usessince_map's one-second clock, andsummarize()finishes the sample only for the last summary (if (now)), so a periodic summary no longer drops up to a second of samples after it.sample_json()sendsbin_middle(): the middle of the 100-unit cell and of the 45-degree yaw and 30-degree pitch bins. The wire format is otherwise unchanged; maps are still named.add_frame()returns whether the frame was a hitch, instead ofperf_frame()summinghitch[]twice a frame.oot_perf_pose()reads the camera's pointers and takes the lock at most every 250 ms (PERF_POSE_EVERY_NS).json_num()callsjson_signed_num(std::max(v, 0.0)).perf_infoandperf_tracking's comments ingpu/vk/vk_api.hgive the pose's order and units and whenhas_poseis 0 (comments only, no ABI change).docs/performance-statistics.md: cells sent by the game, the size limit and thinning, the interval row, the cost. The Graphics guide image's reviewed-source hash advances (docs/images/guide/manifest.json, with a retention note).Needs checking against Longshot-api: I couldn't read the relay's code. The middles land in the same bin as before only if the relay bins with
floor(value / size). If it rounds to the nearest bin, the cells shift by half a cell; changebin_middle()to match it.Measurements
Verdict: the size, game-free: every summary now fits 60 KiB. Frame cost not measured yet: it must be measured in game before this is ready (see Testing).
Hardware: Windows 11, TDM-GCC 64 (g++ -O2), game-free
Method:
summary_json()on the cases below, the sender's re-encoded size (sent_size());tests/test_perf_report.cpp'sadd_frametiming0cece0236de9b0add_frameFlags and settings
None added.
RX_VK_PERF_INTERVALkeeps its default (300) and range (60 to 840); past about five minutes its summaries now carry fewer than one sample a second instead of being refused.Testing
Tested: game-free, on Windows 11 with TDM-GCC.
python -I -B tests/test_perf_report.py: every check passes except "a kept connection the relay let go", which fails the same way onmain@544229a2on this PC. New checks: the biggest summary fits and keeps every map's totals, samples are thinned evenly, cells and bins instead of exact places,add_frame's result,kMaxBodyagainstMAX_BODY, one clock, the summary keeping the second being sampled, and the host's rate limit, camera type, staleness and title clear.hos_perf_info,hos_perf_tracking,oot_perf_pose), cut out and compiled with stubs (gcc -Wall -Wextra). It gives no pose while statistics are off, rate-limits reads, gives none once a pose is a second old, none for another camera type or an absurd angle, and none after a clear.python -I -B scripts/check_guide_screenshots.py --review-sources: passes.python -I -B tests/run_all.py(Windows, 24 at once): 524 passed, 79 failed, 118 skipped.main@544229a2on the same PC: 527 passed, 76 failed, 118 skipped. Four files failed only on this branch:test_audio_voice_biquad,test_gpu_hang_watch,test_longshot_ctlandtest_portable_builder_startup. Run alone, each behaves the same on both:test_audio_voice_biquadfails on both (a missing file), the other three pass on both. One file,test_prepare_at_build, failed only onmain. So these are load-dependent, not regressions. The other failures are this PC's environment (no Vulkan headers, llvm-mingw or spirv-val) and are the same onmain.Not tested: the game itself, and full builds of
host/hos_main.candgpu/vk/perf_report.cpp. This PC has no llvm-mingw or Vulkan headers, and the host's headers come from the game.Must be tested:
LONGSHOT_PERF_URLat a local relay. Play 6 minutes in Hyrule Field, then go back to the title for a minute. Expect a summary of at most 60 KiB with about 300 samples whose x/y/z are multiples of 100 plus 50, and no samples tagged "Title and intro" (by hand: the summary inperf_sent/).RX_VK_PERF_INTERVAL=840, visiting several maps (warp songs). Expect the summary sent, not refused: under 60 KiB, every map's totals, samples spread over the period (by hand: the sender's output andperf_sent/).main, in Hyrule Field. Expect no change in fps or frame times (Test Farm: @Beanstalk linux and windows, five minutes of Hyrule Field with Send performance statistics on and off).Risks
What could break: fewer samples than one a second in long or many-map summaries (by design); no samples in cutscenes or for the first second after a load; if the relay doesn't bin with floor, the cells shift by half a cell.
Turning it off: untick Send performance statistics; otherwise revert this PR (#1372 stays as it was).
Compatibility: nothing changes beyond #1372. The vk ABI is still
MKWVK_API_VERSION30: only comments invk_api.hchanged. Saves, options and caches are unchanged.Checklist
Everyone
type(scope): description) of the status line's type.main. (Stacked on #1372 @0cece02, which is onmain@544229a2.)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.mainand passing here. (Against #1372: itssummary_json()makes 183.8 KB of the biggest case and sends exact positions, which the new checks refuse.)tests/that reads changed source updated in this PR, not weakened.Code-and-evidence review of exact head
36de9b0ce8ab9cb2bea739b025880beef853bd9b, focusing on the two follow-up commits over #1372 at0cece02. No PR code, tests, builds or game runs executed in this review. This is a WIP review, not merge approval.No new blocking code defect found in the follow-up. The serializer retains map totals and thins samples to a conservative re-encoded-size budget; UTF-8 expansion is accounted for conservatively, and the ordinary sender's late version insertion has reserved room. Both coordinate and angular values are reduced to bin centers before serialization. The host's camera-type/finite-value checks, update throttling, stale-age check and title clear address the cited stale/wrong-object pose paths. The common one-second clock and preservation of the partial sample through a periodic summary remove the explicit post-summary sampling gap. Returning the hitch decision from add_frame avoids the previous extra counter scans.
Readiness remains limited by the disclosed integration/evidence gaps:
Farm suitability: useful for cross-platform compilation and ordinary gameplay smoke coverage, but the documented plan schema does not expose writing the launcher's longshot_perf.ini send=1 opt-in or validating the emitted telemetry payloads. A run with that file absent takes perf_report_init's off path and must not be reported as enabled/disabled overhead coverage. No external relay or telemetry submission should be introduced merely to test it.
Verdict: code looks suitable for local integration validation, with merge approval deferred. Our next step is local enabled-path testing using a loopback-only collector and isolated test settings, retaining game-derived artifacts locally; the user requested that local testing be considered before the farm request, so no farm job has been authorized here. A later Linux/Windows farm build/smoke run remains supplemental and must state exactly which telemetry path was exercised.
Review of #1383 at head
36de9b0ce(on top of #1372). Changes needed, mostly about what the relay does with the numbers. This answers the open question in the review above (the relay's binning contract): its source is public, and the first two points below come from it.The size fitting is good. I re-encoded the summaries
summary_jsonmakes through the sender's ownjson.loadandjson.dumpsand all of them stay under 61440 bytes: 16 maps with every count set and 840 samples gives 61042 bytes and 246 samples, 120-byte map names 60993, one map at 300 samples 51130 (all 300 kept). Non-ASCII names and the version and release changes the sender makes fit insidekSenderRoom.Blocking
gpu/vk/perf_report.h:193-194, alsodocs/performance-statistics.md:48). The body says the relay's code could not be read. It is public:cell := fmt.Sprintf("x=%.0f,y=%.0f,z=%.0f", math.Round(s.X/100)*100, math.Round(s.Y/100)*100, math.Round(s.Z/100)*100)math.Round(x/100)*100), not the floor. The middles the game now sends (50, 150, -50) are exact ties, which Go rounds away from zero, so the cell [0,100) is labelledx=100, [-100,0)x=-100, andx=0is never produced. In a Python copy of the relay's two functions, 50.2 percent of random positions got a different cell than the relay gives the exact value. Sending the nearest multiple of 100 (std::round(v / kCell) * kCell) fixes it; the angle bins are fine as they are, if the values are radians (next point).host/hos_main.c:1383-1393,gpu/vk/vk_api.h:271).host/mouse_native.c(lines 1-8, 48) says the camera's yaw and pitch at those offsets are in degrees (yaw wraps at 180, pitch limits -85 to 89), and keeps them on the player camera, whileoot_perf_posereads them from the view at camera+120. The relay refuses the whole summary if any sample has |yaw| over pi or |pitch| over pi/2 (}{{"x", -1e9, 1e9}, {"y", -1e9, 1e9}, {"z", -1e9, 1e9}, {"yaw", -math.Pi, math.Pi}, {"pitch", -math.Pi / 2, math.Pi / 2}}Should fix
host/hos_main.c:1383). Flight (:1455) andhost/oot_fov.c:31-33also testoot_event_playing; a cutscene's camera keeps the same type. Add that test before reading the view.host/hos_main.c:83,:759). A Link update after the title clear sets a pose again and it is served for up to a second under "Title and intro". Return no pose whenmap[0]is empty inhos_perf_info, and clear it where the map line changes (:769).tests/test_perf_report.cpp:122,148,tests/test_perf_report.py:373-399). The size test measures withsent_size, the function under test: withsent_sizecounting no escapes, the tests still pass and the real body of the PR's own biggest case is 61970 bytes, which the sender refuses. The host checks are text searches: a pose that is never marked valid also passes. Re-encode the summary in Python for the size, and commit the stub test of the pose code you describe in the body.const MaxBody = 192 * 1024nx2/perf_report.py:47still says 64 KiB. Raising the sender'sMAX_BODYwould keep all 840 samples; keeping 60 KiB works with the old relay too. Your call and the maintainers', but the comment and the text should say which.README.md:777still says the relay rounds positions and angles.Nit: the even thinning drops the hitch seconds as readily as the quiet ones; keep the seconds with hitches first.
What I ran (Linux, game-free):
tests/test_perf_report.pypasses. The 88 checks that read the changed files plus the C++ unit tests give 86 passed and 6 failed, the same six that fail on #1372's head (test_display_startup_failure,test_hud_layout_row,test_profiling_mode,test_rumble_menu,test_slow_frames,test_walk_key). The Windows-target syntax check fails on both heads with the same "define_CRT_SECURE_NO_WARNINGSbefore the first include" fortest_perf_report.cpp, a line that is on main too. The guide screenshot source check passes. I broke single lines of the fix in scratch copies: five of nine changes were not caught by the tests (list in my notes). The relay's behaviour was checked with a Python copy of its code; Go is not installed here.Not run: the game, any Windows run, a build of the host file, the whole suite, the relay's own tests.
A Linux run is needed: the angles in
perf_pending/against the control bridge's camera value while turning the camera, a summary sent to a real relay and accepted, a trip back to the title, a cutscene and a pause with no pose samples, and frame times with the tick off and on against main.WIP: fix(perf): fit perf summaries under the sender's limit, no stale or cutscene posesto fix(perf): fit perf summaries under the sender's limit, no stale or cutscene poses