diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 22:09:38 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 22:09:38 -0500 |
| commit | 5115f0887940595aa0f46fed7fc9db28b64151ff (patch) | |
| tree | 98b4df97d3b97af290331ea9893587e250c0fac0 /scripts/linux-boot/boot-digest.sh | |
| parent | c8f7515e2e6fb2a2a61eb1e986ee8c6fd4431399 (diff) | |
| parent | b07b9ecb09b47fa6496f01ad9d8fe87d205bd5d8 (diff) | |
Merge main into RT-DIRECT-HEAP-COMPUTE (#1064)
main already supplies the directly indexed heaps to compute dispatches (integration #984, the tree this
pull request was split from): with_direct_heaps()/compute_user_data() on Dispatch and the ExecuteIndirect
dispatch path, RootArgumentLayout::compute_arguments_end (kNoSgpr for a spilled signature),
LEONIDA_COMPUTE_DIRECT_HEAPS=0, and the first form of this test (direct dispatch, indirect after a
resource-only rebind, the GPU read through the heap). That form stays. What this pull request adds beyond
it is carried onto it: the review-round reports, the extra recorded-argument checks, the census tool and
its evidence.
Conflicts:
- runtime/shims/d3d12_com.cpp: main's with_direct_heaps()/compute_user_data() and its one-argument
note_direct_heap_indexing(). Carried: compute_user_data() makes the note itself, so an ExecuteIndirect
dispatch with no heap bound is reported too (record_dispatch's own call removed), and a heap with no
inline dword left is reported once per heap kind ("compute root arguments leave no inline SGPR for the
resource/sampler heap"); a spilled signature (main: kNoSgpr) gets one note of its own. Dropped: the PR's
GetEnvironmentVariableA switch (main's direct_heaps_enabled) and its "graphics heap-base SGPR is not
supplied" notes (main supplies the graphics heaps).
- runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (compute_arguments_end and
graphics_arguments_end with their comment; compute_arguments_end only when the compute arguments do
not spill).
- runtime/test/glsl/cs_user_data.comp: main's; its direct-indexing mode (s5 = 0xFFFFFFFC, heap at s9)
is this pull request's, byte for byte.
- runtime/test/d3d12_compute_test.cpp: the PR's block replaces main's earlier form of it (a superset:
adds the bundle dispatch that inherits the parent's heaps, an indirect dispatch with only the sampler
heap, signatures ending at s30 and s31, and the LEONIDA_COMPUTE_DIRECT_HEAPS=0 expectations).
- docs/d3d12_vulkan.md: main's section 3.4 (the BatchCull s7 and PreSkin s9 evidence), with the PR's
census paragraph (tools/compute_heap_layout_census.py, the seven paired layouts, the heap order as a
hypothesis) and the no-room and spill reports.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/linux-boot/boot-digest.sh')
| -rwxr-xr-x | scripts/linux-boot/boot-digest.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/scripts/linux-boot/boot-digest.sh b/scripts/linux-boot/boot-digest.sh new file mode 100755 index 000000000..dd2289e30 --- /dev/null +++ b/scripts/linux-boot/boot-digest.sh | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # ExecStopPost of a leonida-boot-* unit: runs after the boot ends however it ended (exit, crash, oomd kill, timeout). | ||
| 3 | # Writes /opt/leonida/work/<agent>/boot-<n>.digest.txt and appends a line to /opt/leonida/work/boots.tsv. | ||
| 4 | # Local only: digests quote trace lines, so they never go into commits or PRs. | ||
| 5 | set -u | ||
| 6 | AGENT=$1; N=$2; WORK=/opt/leonida/work/$AGENT; LOG=$WORK/boot-$N.log; RES=$WORK/boot-$N.resources.tsv | ||
| 7 | META=$WORK/boot-$N.meta; OUT=$WORK/boot-$N.digest.txt; LEDGER=/opt/leonida/work/boots.tsv | ||
| 8 | START=$(sed -n 's/^start_epoch=//p' "$META" 2>/dev/null); BOOT=$(sed -n 's/^boot_epoch=//p' "$META" 2>/dev/null) | ||
| 9 | START=${START:-$(date +%s)}; BOOT=${BOOT:-$START}; END=$(date +%s) | ||
| 10 | RESULT=${SERVICE_RESULT:-?}; ECODE=${EXIT_CODE:-?}; ESTAT=${EXIT_STATUS:-?} | ||
| 11 | D3D=$(grep -o 'd3d12=[^ ]*' "$LOG" 2>/dev/null | tail -1 | cut -d= -f2) | ||
| 12 | STDOUT=${D3D/d3d12-run-/stdout-run-} | ||
| 13 | CAP=/opt/leonida/capture/$AGENT-$N | ||
| 14 | |||
| 15 | verdict=OK | ||
| 16 | # systemd-oomd can kill the unit's processes without the unit ending in "oom-kill" (boot.sh then exits on its own). | ||
| 17 | if journalctl --user -u "leonida-boot-$AGENT-$N" --since "@$START" -q --no-pager 2>/dev/null | grep -q 'systemd-oomd killed'; then RESULT=oom-kill; fi | ||
| 18 | case "$RESULT" in | ||
| 19 | oom-kill) verdict="KILLED BY OOM (systemd-oomd or kernel): memory, not a crash" ;; | ||
| 20 | timeout) verdict="TIMEOUT" ;; | ||
| 21 | exit-code) verdict="EXITED WITH ERROR (code $ECODE status $ESTAT)" ;; | ||
| 22 | signal|core-dump) verdict="KILLED BY SIGNAL ($ESTAT)" ;; | ||
| 23 | success) verdict="OK (ran to its time limit or exited cleanly)" ;; | ||
| 24 | esac | ||
| 25 | grep -q 'time limit reached' "$LOG" 2>/dev/null && [ "$RESULT" = success ] && verdict="OK (ran its full time limit)" | ||
| 26 | |||
| 27 | cnt() { local c=0; [ -f "$D3D" ] && c=$(grep -a -c -E "$@" "$D3D"); echo "${c:-0}"; } | ||
| 28 | { | ||
| 29 | echo "== leonida boot $AGENT-$N: $verdict" | ||
| 30 | echo "unit result=$RESULT exit_code=$ECODE exit_status=$ESTAT" | ||
| 31 | echo "queued $((BOOT-START)) s, ran $((END-BOOT)) s; trace $D3D" | ||
| 32 | sed -n '/^LEONIDA_\|^WINEDEBUG\|^unit=/p' "$META" 2>/dev/null | tr '\n' ' '; echo | ||
| 33 | echo | ||
| 34 | echo "-- counts" | ||
| 35 | echo "PresentX ok $(cnt 'XboxPresentation::PresentX ok') refused $(cnt 'XboxPresentation::PresentX failed')" | ||
| 36 | echo "CreatePipelineState failed $(cnt 'CreatePipelineState failed') FSPX compute misses $(cnt 'no translated compute shader for FSPX') slot-67 failed $(cnt 'slot 67 call .* failed')" | ||
| 37 | echo "E_NOTIMPL $(cnt 'E_NOTIMPL') wine err: lines $(cnt '^[0-9a-f]{4}:err:|:err:') exceptions $(cnt -i 'exception|unhandled|page fault|access violation')" | ||
| 38 | grep -a -m1 -E 'translated shaders \(' "$D3D" 2>/dev/null | ||
| 39 | grep -a 'present-probe: source frame .* via' "$D3D" 2>/dev/null | tail -1 | sed 's/.*via/source via/' | cut -c1-120 | ||
| 40 | echo | ||
| 41 | echo "-- frames (swapchain; then the title's own backbuffer when LEONIDA_CAPTURE_SOURCE=1)" | ||
| 42 | [ -f "$CAP/index.txt" ] && { echo "$(wc -l < "$CAP/index.txt") captured; last: $(tail -1 "$CAP/index.txt" | cut -c1-110)"; awk '{m=$(NF-2)+$(NF-1)+$NF; if (m>0) n++} END{print n+0 " of " NR " frames non-black"}' "$CAP/index.txt"; } || echo "no capture index" | ||
| 43 | grep -a 'present-probe: source frame .* mean' "$D3D" 2>/dev/null | tail -2 | sed 's/.*source frame/source frame/' | cut -c1-140 | ||
| 44 | echo | ||
| 45 | echo "-- resources (2 s samples)" | ||
| 46 | [ -s "$RES" ] && awk -F'\t' 'NR>1{ if(min==""||$2<min)min=$2; if($3>sw)sw=$3; if($4>um)um=$4; if($5>us)us=$5; if($6+0>gm)gm=$6 } END{printf "min RAM available %s MB, max swap used %s MB, game peak %s MB RAM + %s MB swap, VRAM peak %s MB\n",min,sw,um,us,gm}' "$RES" || echo "no samples" | ||
| 47 | journalctl --user -u "leonida-boot-$AGENT-$N" --since "@$START" -q --no-pager 2>/dev/null | grep -E 'Consumed|oom|Failed' | sed 's/^.*\]: //' | sort -u | cut -c1-200 | ||
| 48 | # Compare with other boots instead of guessing: on the console (Series S) path the title itself grows to ~20 GB of | ||
| 49 | # RAM+swap by ~130 s (fsdraw-6: 9.9 GB + 11.2 GB), mostly zero pages that zram compresses well. | ||
| 50 | [ -s "$RES" ] && awk -F'\t' 'NR>1{t=$4+$5; if(t>m)m=t} END{printf "game peak RAM+swap %.1f GB (console-path baseline ~20 GB at 130 s; oomd kills when zram swap passes 98%%)\n", m/1024}' "$RES" | ||
| 51 | echo | ||
| 52 | echo "-- system events during the boot (OOM, GPU Xid, segfaults)" | ||
| 53 | { journalctl --since "@$BOOT" -q --no-pager 2>/dev/null | grep -i -E 'systemd-oomd.*(Marked|killed)|oom-kill|out of memory|NVRM: Xid|segfault|gta6rt|wineserver.*crash' ; } | cut -c1-200 | tail -15 | ||
| 54 | echo | ||
| 55 | echo "-- distinct error lines (normalised, with counts; top 60)" | ||
| 56 | for f in "$D3D" "$STDOUT"; do [ -f "$f" ] && cat "$f"; done 2>/dev/null \ | ||
| 57 | | grep -a -i -E 'error|fail|E_NOTIMPL|E_INVALIDARG|E_FAIL|0x8[0-9a-f]{7}|exception|assert|abort|unhandled|page fault|refused|not implemented|no translated|no emulation|crash|:err:|fatal|cannot|could not|unsupported|invalid' \ | ||
| 58 | | grep -a -v -E ' ok$| called$' \ | ||
| 59 | | sed -E 's/#[0-9]+/#N/g; s/0x[0-9a-fA-F]{6,}/0xADDR/g; s/\b[0-9a-f]{64}\b/SHA/g; s/[0-9]{4,}/NUM/g; s/^[0-9a-f]{4}:/TID:/' \ | ||
| 60 | | cut -c1-220 | sort | uniq -c | sort -rn | head -60 | ||
| 61 | echo | ||
| 62 | echo "-- where the trace ended" | ||
| 63 | [ -f "$D3D" ] && tail -n 8 "$D3D" | cut -c1-200 | ||
| 64 | } > "$OUT" 2>&1 | ||
| 65 | |||
| 66 | frames=$( [ -f "$CAP/index.txt" ] && awk '{m=$(NF-2)+$(NF-1)+$NF; if (m>0) n++} END{print (n+0) "/" NR}' "$CAP/index.txt" || echo "-") | ||
| 67 | peak=$( [ -s "$RES" ] && awk -F'\t' 'NR>1{if($4>u)u=$4} END{print u+0}' "$RES" || echo "-") | ||
| 68 | exec 7>>"$LEDGER"; flock 7 | ||
| 69 | # Both the unit's ExecStopPost and the outer wrapper call this; the first one to finish records the boot. | ||
| 70 | grep -q -P "^[^\t]*\t$AGENT\t$N\t" "$LEDGER" 2>/dev/null && exit 0 | ||
| 71 | [ -s "$LEDGER" ] || printf 'end\tagent\tn\tresult\tran_s\tpresentx_ok\tpso_failed\tfspx_miss\tnonblack_frames\tpeak_mb\tgta6rt\n' >&7 | ||
| 72 | printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$(date '+%F %T')" "$AGENT" "$N" "$RESULT" "$((END-BOOT))" \ | ||
| 73 | "$(cnt 'XboxPresentation::PresentX ok')" "$(cnt 'CreatePipelineState failed')" "$(cnt 'no translated compute shader for FSPX')" \ | ||
| 74 | "$frames" "$peak" "$(sed -n 's/^unit=.*gta6rt=\([^ ]*\).*/\1/p' "$META")" >&7 | ||
| 75 | exit 0 | ||