fix(scripts): the profile readers name and count Linux samples #1746

Merged
Joey-Magnus merged 1 commit from fix/profilers-linux into main 2026-11-10 16:49:54 +00:00
Joey-Magnus commented 2026-11-10 15:23:15 +00:00 (Migrated from github.com)

The profile readers only knew the Windows module names, so on Linux scripts/crit.py reported every thread as never running and named nothing. That made it useless for the Kokiri Forest stutter investigation (#dev-work), where the critical path is exactly what's needed.

What changes

  • scripts/prof.py: load_symbols() reads the Windows linker maps as before, and for the Linux build the binaries' own symbols with nm (hookshot, hookshot_vk.so). Point RX_MAPS at the game folder. RUN_MODS and module_name() are shared.
  • crit.py, vkprof.py, hotlist.py and prof.py use it. vkprof.py also counts Linux driver leaves (libnvidia-glcore.so, RADV, ANV) as running, as it does nvoglv64.dll.
  • docs/development.md: one line on RX_MAPS for Linux.

Testing

  • New tests/test_prof_symbols.py. It builds a small PIE named hookshot that prints its own function offsets from its load address (as a sample records them), then runs crit.py and hotlist.py on synthetic samples: a thread in hookshot must count as running, one in libc as blocked, and the lifted function must be named. A synthetic hookshot.map checks that the Windows path is unchanged. It fails on main and passes here. The ELF part skips without a C compiler and nm.
  • python -I -B tests/run_all.py: 239 passed, 0 failed (Linux).
  • Real run: RX_MAPS=<game folder> python -I scripts/crit.py <HOS_SAMPLE_ALL file> on a Kokiri sample now gives Presentation_Thread 27.5% running and sead::MainThread 13.5%, with the main thread's waits named (f_81207a50, f_806668b0, f_8007fe60). Before it was 0.0% for every thread.

Tested on: Ubuntu 26.04, RTX 4070 Ti, driver 595.99.02, Ryzen 7 9800X3D.

🤖 Generated with Claude Code

The profile readers only knew the Windows module names, so on Linux `scripts/crit.py` reported every thread as never running and named nothing. That made it useless for the Kokiri Forest stutter investigation (#dev-work), where the critical path is exactly what's needed. **What changes** - `scripts/prof.py`: `load_symbols()` reads the Windows linker maps as before, and for the Linux build the binaries' own symbols with `nm` (`hookshot`, `hookshot_vk.so`). Point `RX_MAPS` at the game folder. `RUN_MODS` and `module_name()` are shared. - `crit.py`, `vkprof.py`, `hotlist.py` and `prof.py` use it. `vkprof.py` also counts Linux driver leaves (`libnvidia-glcore.so`, RADV, ANV) as running, as it does `nvoglv64.dll`. - `docs/development.md`: one line on `RX_MAPS` for Linux. **Testing** - New `tests/test_prof_symbols.py`. It builds a small PIE named `hookshot` that prints its own function offsets from its load address (as a sample records them), then runs `crit.py` and `hotlist.py` on synthetic samples: a thread in `hookshot` must count as running, one in libc as blocked, and the lifted function must be named. A synthetic `hookshot.map` checks that the Windows path is unchanged. It fails on `main` and passes here. The ELF part skips without a C compiler and `nm`. - `python -I -B tests/run_all.py`: 239 passed, 0 failed (Linux). - Real run: `RX_MAPS=<game folder> python -I scripts/crit.py <HOS_SAMPLE_ALL file>` on a Kokiri sample now gives Presentation_Thread 27.5% running and sead::MainThread 13.5%, with the main thread's waits named (`f_81207a50`, `f_806668b0`, `f_8007fe60`). Before it was 0.0% for every thread. Tested on: Ubuntu 26.04, RTX 4070 Ti, driver 595.99.02, Ryzen 7 9800X3D. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
hckrman101 (Migrated from github.com) approved these changes 2026-11-10 16:41:05 +00:00
hckrman101 (Migrated from github.com) left a comment

Looks good. Read through all five scripts and the test: the Windows map path is unchanged (same bases, same .map lookup), the Linux path uses nm offsets that match what a sample records for a PIE/shared object, and RUN_MODS/module_name() are shared sensibly. The new test is picked up by run_all's tests/test_*.py glob, covers both the map and ELF paths, and skips cleanly without cc/nm. CI is green.

Nits only, no need to change anything: prof.py main() now honors RX_MAPS (it used the build dir before), which is what you'd want; and the libnvidia-glcore.so etc. prefixes in vkprof.py will miss other drivers (e.g. lavapipe), which is fine for now.

Looks good. Read through all five scripts and the test: the Windows map path is unchanged (same bases, same `.map` lookup), the Linux path uses nm offsets that match what a sample records for a PIE/shared object, and `RUN_MODS`/`module_name()` are shared sensibly. The new test is picked up by run_all's `tests/test_*.py` glob, covers both the map and ELF paths, and skips cleanly without cc/nm. CI is green. Nits only, no need to change anything: `prof.py main()` now honors `RX_MAPS` (it used the build dir before), which is what you'd want; and the `libnvidia-glcore.so` etc. prefixes in vkprof.py will miss other drivers (e.g. lavapipe), which is fine for now.
Commenting is not possible because the repository is archived.
No description provided.