feat(profiling): a profile folder carries the renderer's symbols, so a tester's zip is named anywhere #2862

Merged
HumanBean merged 1 commit from HumanBean/Longshot:push-pnyqsuyxrmsx into main 2026-11-30 03:46:10 +00:00
Owner

Summary

A profile folder from a tester (HOS_PROFILE=1) could only be named on a PC that has the same build. Now the run also writes symbols into the folder: the renderer's (longshot_vk.so / longshot_vk.dll, our own code) function symbols as sorted <hex offset> <name> lines (mangled; the scripts demangle). Linux reads the ELF .symtab (else .dynsym) itself, so a player needs no binutils; Windows takes the code section of longshot_vk.map when it sits beside the game. No renderer or no symbols: a one-line # no symbols: <why> file. Written once at start on its own thread. It is about 1.3 MB of text (about 230 KB zipped) for a current Linux build (17k functions).

The game module (longshot, longshot.exe) is never read or written: nothing made from the game leaves the PC. The test checks that a stand-in game module's symbols stay out and that the source never names it.

scripts/profiling/symbols.py (load_symbols_file, used by load_symbols), folder.py (default_maps: the game folder, else the folder's own symbols) and scripts/perf.py (threads/renderer/stacks default their symbols to the sample file's folder when it has symbols) read it, so an unpacked zip names the renderer's frames anywhere; the game's frames stay longshot+<offset>. Docs: docs/dev/reference/profiling.md, docs/user/performance-report.md. Read first: host/profiling.c (symbols_collect).

Testing

Tested: Linux only, game-free. This did not run in the game (no game run, per the person I work for). tests/test_profile_symbols.py cuts the symbols code out of host/profiling.c, compiles it with a stub beside a small longshot_vk.so (C and C++ names) and a stand-in longshot, and checks the file equals nm's function symbols, sorted, the game module absent, the note without a renderer, and a frame named through symbols.py/folder.py. host/profiling.c also passes gcc -fsyntax-only -Wall -Wextra with the host/posix shim. test_profiling_mode.py, test_profile_report_names.py and test_perf_report.py pass.

Still to test:

  • Linux, any GPU: a HOS_PROFILE=1 run writes symbols in the folder, and perf.py report on a copy of the folder away from the game folder names longshot_vk: frames (by hand)
  • Windows: the same with longshot_vk.map beside the game; that branch has not been compiled or run (by hand)

Measurements

Nothing to measure: a diagnostic mode's folder gains one file, written once on a side thread at start, off by default.

Risks

Profiling mode only (off by default). A side thread reads about 18 MB of the .so once at start and writes about 1.3 MB; a failure writes the note and nothing else. A revert is enough. The Windows map reader is unproven.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (not run in the game; --force allowed by the person I work for)
  • mise run test passes. (only the touched profiling tests and test_perf_report.py were run, all passing)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux syntax check only; the Windows branch is not compiled)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
## Summary A profile folder from a tester (HOS_PROFILE=1) could only be named on a PC that has the same build. Now the run also writes `symbols` into the folder: the renderer's (`longshot_vk.so` / `longshot_vk.dll`, our own code) function symbols as sorted `<hex offset> <name>` lines (mangled; the scripts demangle). Linux reads the ELF `.symtab` (else `.dynsym`) itself, so a player needs no binutils; Windows takes the code section of `longshot_vk.map` when it sits beside the game. No renderer or no symbols: a one-line `# no symbols: <why>` file. Written once at start on its own thread. It is about 1.3 MB of text (about 230 KB zipped) for a current Linux build (17k functions). The game module (`longshot`, `longshot.exe`) is never read or written: nothing made from the game leaves the PC. The test checks that a stand-in game module's symbols stay out and that the source never names it. `scripts/profiling/symbols.py` (`load_symbols_file`, used by `load_symbols`), `folder.py` (`default_maps`: the game folder, else the folder's own `symbols`) and `scripts/perf.py` (`threads`/`renderer`/`stacks` default their symbols to the sample file's folder when it has `symbols`) read it, so an unpacked zip names the renderer's frames anywhere; the game's frames stay `longshot+<offset>`. Docs: `docs/dev/reference/profiling.md`, `docs/user/performance-report.md`. Read first: `host/profiling.c` (`symbols_collect`). ## Testing **Tested:** Linux only, game-free. This did not run in the game (no game run, per the person I work for). `tests/test_profile_symbols.py` cuts the symbols code out of `host/profiling.c`, compiles it with a stub beside a small `longshot_vk.so` (C and C++ names) and a stand-in `longshot`, and checks the file equals nm's function symbols, sorted, the game module absent, the note without a renderer, and a frame named through `symbols.py`/`folder.py`. `host/profiling.c` also passes `gcc -fsyntax-only -Wall -Wextra` with the host/posix shim. `test_profiling_mode.py`, `test_profile_report_names.py` and `test_perf_report.py` pass. **Still to test:** - Linux, any GPU: a HOS_PROFILE=1 run writes `symbols` in the folder, and `perf.py report` on a copy of the folder away from the game folder names `longshot_vk:` frames (by hand) - Windows: the same with `longshot_vk.map` beside the game; that branch has not been compiled or run (by hand) ## Measurements Nothing to measure: a diagnostic mode's folder gains one file, written once on a side thread at start, off by default. ## Risks Profiling mode only (off by default). A side thread reads about 18 MB of the .so once at start and writes about 1.3 MB; a failure writes the note and nothing else. A revert is enough. The Windows map reader is unproven. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (not run in the game; `--force` allowed by the person I work for) - [ ] `mise run test` passes. (only the touched profiling tests and `test_perf_report.py` were run, all passing) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux syntax check only; the Windows branch is not compiled) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers.
feat(profiling): a profile folder carries the renderer's symbols, so a tester's zip is named anywhere
Some checks failed
CI / What the change needs (pull_request) Successful in 23s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been skipped
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been skipped
CI / Third-party parts and guide screenshots (pull_request) Failing after 33s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Failing after 22s
PR description / Title and description (pull_request_target) Failing after 11s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m52s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m5s
CI / Website build and checks (pull_request) Failing after 35s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 18m9s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 39m23s
b75f67c351
host/profiling.c writes symbols (longshot_vk.so's ELF function symbols, or longshot_vk.map's code section on Windows) into
the HOS_PROFILE=1 folder; symbols.py, folder.py and perf.py read it. Never the game module's symbols.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Member

Possibly related, for context:

  • PR #1347 fix(scripts): the profile readers count a Windows wait as a wait and name the renderer's functions — Open profiling-reader work overlaps symbol naming
  • PR #1321 fix(profiling): a Windows profile names its C++ code, counts its waits as waits, and gives a thread one row — Merged profiling symbol demangling groundwork
Possibly related, for context: - PR #1347 fix(scripts): the profile readers count a Windows wait as a wait and name the renderer's functions — Open profiling-reader work overlaps symbol naming - PR #1321 fix(profiling): a Windows profile names its C++ code, counts its waits as waits, and gives a thread one row — Merged profiling symbol demangling groundwork
HumanBean changed title from WIP: feat(profiling): a profile folder carries the renderer's symbols, so a tester's zip is named anywhere to feat(profiling): a profile folder carries the renderer's symbols, so a tester's zip is named anywhere 2026-11-30 03:46:03 +00:00
HumanBean deleted branch push-pnyqsuyxrmsx 2026-11-30 03:46:10 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2862
No description provided.