Skip to content

Benchmark: frame stall diagnostics, cooling gate and presentation timing - #315

Merged
mamcjr merged 2 commits into
mamcjr:mainfrom
Propinbo:benchmark-v2
Nov 17, 2026
Merged

mamcjr merged 2 commits into
mamcjr:mainfrom
Propinbo:benchmark-v2

Conversation

@Propinbo

@Propinbo Propinbo commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Part of #214; follows #278.

What it does

Adds per-frame counters for pipeline compilation/waits, GPU waits, texture uploads/BC/ASTC decoding and file reads, with a likely cause for each period above the 30 fps budget. Loading and warm-up remain in frames.csv; report.json summarizes the measurement window. Measurements can overlap; this is not an exclusive breakdown.

Optional cooling waits until Android thermal status is at or below thermal_max, after title appears, before each scene/repeat. thermal_wait_s bounds the wait; unavailable status or timeout gives harness_error. Headroom is budget minus max(CPU,GPU), with unknown GPU samples left missing. Game periods and actual presentation metrics are separate. Presentation uses VK_GOOGLE_display_timing, retains early feedback in synchronous rendering and counts missing feedback.

How to turn it on

Use the same scene file and launch intent as #278; optionally add:

thermal_max = 1
thermal_wait_s = 300
adb push tools/benchmark-scenes.txt /sdcard/Android/data/com.botwrecomp.android/files/scenes.txt
adb shell am start -n com.botwrecomp.android/com.botwrecompandroid.BOTWRecompAndroidActivity --es env LARECOMP_BENCHMARK=/sdcard/Android/data/com.botwrecomp.android/files/scenes.txt

Reports go to <scene file>.out/ (report format 2). Without the variable the new diagnostic counters, clocks and trace collection are disabled.

How it was checked

SM-X730, Mali-G925 (r49p1), Android 16, BOTW 1.9.0, Recompiled, 120 Hz, on USB. Final clean commit 346eaea: three scenes (plateau, Hateno lab/village), two repeats, 45 s windows: 6/6 ok, 1351 frames each, 30.00 fps, no game period over 50 ms. Game p99 33.695-33.927 ms; headroom p50 6.039-6.502 ms. Presentation p99 33.446-41.706 ms, no missing feedback or presentation period over 50 ms. CSV-to-JSON recomputation passes.

An earlier attempt stalled after two windows while waiting for a guest thread during reboot; a fresh full retry passed. Cause of that reboot stall is unknown. There was no timeout; follow-up commit 8ec0867 adds a 60-second watchdog from the scene reboot request until the old guest threads stop, before the next game boot/load; it writes harness_error at reboot and exits (forced-wait test passed; normal short run 2/2 ok).

One empty-cache lab boot on the same commit: 1509 completed builds; 18 periods over 50 ms attributed to pipeline waits, excluding the first incomplete interval. Example from frames.csv, frame 494 during arrival (outside the window):

Measurement ms
Game period 1618.707
Blocking pipeline wait 1531.687
GPU timeline wait 2.206
Texture upload, including decode 21.634
BC decode (included above) 21.381
ASTC decode / file reads 0 / 0

317 builds completed in that interval (3838.833 ms of overlapping worker time); likely cause pipeline_wait. Unknown GPU busy/headroom stays empty. After warm-up: 30.00 fps, no game period over 50 ms.

Flag off vs stock v0.3.2-beta: ABBAAB, three 100 s boots each, same scene, last 900 frames. Median of per-run CPU p50: stock 19.430 ms, benchmark 19.180 ms (-1.29%); within-version ranges 1.130/0.560 ms. The difference is smaller than both spreads: no stable overhead detected, not proof of zero cost. This series used 60813bb; 346eaea adds the title/feedback fixes. No benchmark logs or reports without the flag.

Cooling was separately checked with a temporary Android status override: waited 60.519 s at title, status 1 to 0, then loaded at 0. Sync renderer (LARECOMP_VK_ASYNC=0) had 0 missing feedback in 118 window frames; ordinary mode 0 in 151. Android host regression tests and APK build pass. Source save/settings/cache hashes unchanged; original APK restored after scratch-only runs.

The relaxed-atomic counters and largest-stall heuristic are adapted from SavageWindRecomp, MIT. Copyright notices and full permission text are retained in third_party/licenses/SavageWindRecomp.txt; measurement limits are in docs/BENCHMARK.md.

Merge Danger

Door: two-way

Revert removes these additions. No save format, settings format or game-code changes.

Blast Radius: small

Without the benchmark flag, the added hooks are bool checks with no diagnostic collection or report writes. With it, reports use format 2 and the reboot watchdog can terminate a stalled run; scratch-save handling and game-memory edits remain as in #278. A run updates its shader cache, like a normal session.

@mamcjr

mamcjr commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Thanks for this! It now conflicts with main (exec.c, device.c, textures.c, async.c changed with the growable caches and the pipeline limit). Could you rebase it? I'd also like to understand where third_party/licenses/SavageWindRecomp.txt comes from (which code it covers), and to check that the counters cost nothing with the benchmark off.

@Propinbo

Copy link
Copy Markdown
Contributor Author

Rebased onto 65c3d478. The PR tip is 674c8b0. Debug and Release built, and all six Android host regressions and three standalone upstream checks passed.

pipeline_wait still measures the existing wait_built() intervals. The cap adds no blocking wait. The report tracks eviction time, evictions and rebuild requests separately. Growable program and pipeline caches follow main. Texture instrumentation respects cache hits, dirty checks and discard skips, and times uploads before guest-page discard, with separate BC/ASTC decode timings. GPU wait timing skips cached completions and the background sequence waiter. Ordered texture-slot writes follow upstream, and render-queue backpressure, wait-id and drain remain outside stall attribution.

third_party/licenses/SavageWindRecomp.txt matches the upstream MIT LICENSE at 257b1f3c348a1863703d44a619c10650e25e5155 byte for byte, including both copyright notices. The adaptations are:

  • runtime/benchmark_perf.h cumulative relaxed-atomic counters from runtime/perfcount.h L9–27.
  • runtime/hle/benchmark_trace.c snapshots, frame deltas and largest-stall attribution from runtime/control_prof.c L38, L72–94 and tools/perf_routes.py L373–418.
  • Counter placement follows the same upstream paths in runtime/nvn/vulkan/exec.c L203, L2798, L2886, L3670, L6485 and L7251–52, runtime/nvn/vulkan/textures.c L1017 and L1218, and runtime/services/fs.c L1237–42 and L1389–94. Cooling, the reboot watchdog, presentation matching and report integration were written for this PR.

Release ARM64 shows flag loads and branches around the diagnostic updates. Timed paths such as file reads and texture uploads also check the saved start timestamp on exit. With LARECOMP_BENCHMARK unset, those paths skip diagnostic clocks, atomics and collection. Existing Vulkan display-timing queries still serve upstream pacing.

I reran ABBAAB on the SM-X730 against 65c3d478, with the flag unset and the last 900 pace samples from each of three 100-second boots per build. The measured B runtime was e9a6390. The tip 674c8b0 adds an NVN lifetime test-only commit. Median CPU p50 was 19.190 vs 19.225 ms, a change of +0.035 ms (+0.18%). Median CPU p99 was 23.330 vs 23.800 ms, a change of +0.470 ms (+2.01%). Both changes were smaller than either build's corresponding run-to-run spread. The series detected no measurable overhead at that resolution and cannot establish zero cost. Stock [pace] excludes intervals above 100 ms, so these numbers do not characterize rare long stalls.

@mamcjr

mamcjr commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the answers, sorry for the delay. The licence and the cost data settle it: third_party/licenses/SavageWindRecomp.txt matches upstream's LICENSE at 257b1f3, and with the benchmark off the hot paths only gain a flag check (no clock reads, no atomics, no change to when VK_GOOGLE_display_timing is enabled).

Main moved again, so there's one small conflict now: vk_wait_seq() in exec.c, from b8a1d05 (Turnip per-submission fences). Please rebase onto current main, keep main's seq_fences_on ? seq_wait_done(...) branch, and count those waits as GPU wait too (they are real GPU waits). One nit while you're there: the #include "../../benchmark_perf.h" lines sit above each file's header comment; below it matches the rest. Then I'll merge.

Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 17, 2026
…30 A/B + clock check, and 11-scene audit [skip ci]
@Propinbo

Propinbo commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review — I have rebased the PR branch (pr315-benchmark-v2, 674c8b0 -> dd13412 + d928ccc) onto current main (6113c61 / v0.4.5-beta):

  • Resolved vk_wait_seq conflict (runtime/nvn/vulkan/exec.c): Preserved main's seq_fences_on ? seq_wait_done(...) : ... wait path and wrapped it with BP_GPU_WAIT_NS so timeline-semaphore waits remain intact while GPU wait time is attributed to gpu_wait_ns.
  • Restored file header comments: Moved #include "../../benchmark_perf.h" below the top-of-file descriptions in runtime/nvn/vulkan/async.c, device.c, exec.c, and textures.c so none of the existing comments at line 1 were shifted or obscured.
  • Included runtime test fix (d928ccc): Added low-RAM queue stubs (vk_low_ram, vk_async_call) in tools/test_nvn_lifetime.c so test_nvn_lifetime compiles and passes alongside test_benchmark_trace.
  • Re-verified on Android (SM-X730, Mali-G925):
    • tools/test_android_runtime.ps1: 6/6 Bionic tests passed (test_kernel_affinity, test_bc_shadow, test_buffer_copy, test_nvn_lifetime, test_object_cache, test_benchmark_trace).
    • ./gradlew assembleDebug: passed (BUILD SUCCESSFUL).

@mamcjr

mamcjr commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks, the rebase is right: main's fences path is kept and its waits counted as GPU wait, and the includes are below the headers. Merging.

@mamcjr
mamcjr merged commit ac38c7a into mamcjr:main Nov 17, 2026
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 17, 2026
…device

Replaces 4 poorly framed/obstructed or redundant views in the earlier set
with visually audited, shrine-free MainField scenes (Korok Plaza, South
Akkala foliage, Faron jungle, Zora Plaza rain, Hateno Dye Shop interior,
and unobstructed Lake Hylia pier) while retaining 0.0 drift and <= 0.52 u
height delta across 24/24 measured 45s windows on SM-X730 (Mali-G925,
v0.4.5-beta + mamcjr#315). Caveats and methodology limits are recorded in
tools/benchmark-scenes-extended.md.
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants