Linux: profiling the runtime under Proton without perf or root #236

Open
fsrajner wants to merge 2 commits from upstream-pr/236 into main
fsrajner commented 2026-11-29 22:42:34 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by fsrajner on 2026-11-29T22:42:34Z.


Builds on #234 (its one commit is included here; it lets .c and .py files pass the asset policy).

scripts/linux/prof: a perf_event_open sampler, symbolizers for victory.exe (PDB), PE images (exports) and ELF objects (Wine's ntdll.so, wineserver, libc), per-thread CPU time and off-CPU states. kernel.perf_event_paranoid=2, the usual default, allows this for your own processes, so it works on desktops without perf or sudo. The README has a typical round.

These found, on one PC, the wineserver walking its whole list of views at every map and unmap (Wine bug 60868) and the kernel walking every userptr page at every submission.

Nothing in the runtime changes. Tested: sampler.c builds with cc -O2 -Wall, the Python scripts compile, and all of it was used for the measurements behind the Linux notes PR; cargo xtask policy passes.

🤖 Generated with Claude Code

<!-- greyfinch-sync:DexNom/VIctory:issue:5555938951 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/236). Originally posted by [fsrajner](https://github.com/fsrajner) on 2026-11-29T22:42:34Z. --- Builds on #234 (its one commit is included here; it lets `.c` and `.py` files pass the asset policy). `scripts/linux/prof`: a `perf_event_open` sampler, symbolizers for victory.exe (PDB), PE images (exports) and ELF objects (Wine's `ntdll.so`, `wineserver`, libc), per-thread CPU time and off-CPU states. `kernel.perf_event_paranoid=2`, the usual default, allows this for your own processes, so it works on desktops without `perf` or sudo. The README has a typical round. These found, on one PC, the wineserver walking its whole list of views at every map and unmap (Wine bug 60868) and the kernel walking every userptr page at every submission. Nothing in the runtime changes. Tested: `sampler.c` builds with `cc -O2 -Wall`, the Python scripts compile, and all of it was used for the measurements behind the Linux notes PR; `cargo xtask policy` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Zippp69 commented 2026-11-30 16:44:40 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T16:44:40Z.


Review of d5e5b8f

Pass the elapsed duration to statdiff.py. The README invokes ./statdiff.py before.txt after.txt, but the script requires a third argument. I reproduced the IndexError using synthetic snapshots and verified that providing the elapsed seconds produces the expected CPU percentage. Document the duration between snapshots, including the sampling window. README · statdiff.py

Use the recorded PE mapping to symbolize samples. Two synthetic maps with a mocked LLVM subprocess reproduced both failures. With a space in DexNom Runtime/victory.exe, split() truncated the path and the script sent no sample for symbolization. With a relocated executable and no spaces, it sent the live address 0x150001120 where the preferred-image address is 0x140001120. Preserve the pathname using a bounded split, identify the image from its mappings, and translate the sampled IP to the preferred image address before invoking the symbolizer. analyze.py

<!-- greyfinch-sync:DexNom/VIctory:comment:7285159233 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/236#issuecomment-7285159233). Originally posted by [Zippp69](https://github.com/Zippp69) on 2026-11-30T16:44:40Z. --- Review of `d5e5b8f` **Pass the elapsed duration to statdiff.py.** The README invokes `./statdiff.py before.txt after.txt`, but the script requires a third argument. I reproduced the `IndexError` using synthetic snapshots and verified that providing the elapsed seconds produces the expected CPU percentage. Document the duration between snapshots, including the sampling window. [README](https://github.com/DexNom/VIctory/blob/d5e5b8fc7c62afaf4d6bb3fde585f986260cd1e4/scripts/linux/prof/README.md#L18-L27) · [statdiff.py](https://github.com/DexNom/VIctory/blob/d5e5b8fc7c62afaf4d6bb3fde585f986260cd1e4/scripts/linux/prof/statdiff.py#L4-L13) **Use the recorded PE mapping to symbolize samples.** Two synthetic maps with a mocked LLVM subprocess reproduced both failures. With a space in `DexNom Runtime/victory.exe`, `split()` truncated the path and the script sent no sample for symbolization. With a relocated executable and no spaces, it sent the live address `0x150001120` where the preferred-image address is `0x140001120`. Preserve the pathname using a bounded split, identify the image from its mappings, and translate the sampled IP to the preferred image address before invoking the symbolizer. [analyze.py](https://github.com/DexNom/VIctory/blob/d5e5b8fc7c62afaf4d6bb3fde585f986260cd1e4/scripts/linux/prof/analyze.py#L14-L47)
Zippp69 commented 2026-11-30 16:50:48 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T16:50:48Z.


Tested documentation fix for the missing elapsed duration. Follow-up to the profiling review at d5e5b8f. Mark the example as Bash, start its elapsed-seconds counter before the first snapshot, and pass that duration to statdiff.py after the second snapshot. I verified the script on synthetic snapshots. A change of 100 user ticks across two seconds reports 50% of one core.

-```sh
+```bash
 pid=$(pgrep -f 'victory.exe' | head -1)
 cat /proc/$pid/maps > maps.txt
+SECONDS=0
 ./statsnap.sh $pid > before.txt
 ./sampler $pid 20 > samples.txt & ./offcpu.py $pid 20 offcpu.txt; wait
 ./statsnap.sh $pid > after.txt
-./statdiff.py before.txt after.txt
+./statdiff.py before.txt after.txt "$SECONDS"
<!-- greyfinch-sync:DexNom/VIctory:comment:7285320125 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/236#issuecomment-7285320125). Originally posted by [Zippp69](https://github.com/Zippp69) on 2026-11-30T16:50:48Z. --- **Tested documentation fix for the missing elapsed duration.** Follow-up to [the profiling review](https://github.com/DexNom/VIctory/pull/236#issuecomment-7285159233) at `d5e5b8f`. Mark the example as Bash, start its elapsed-seconds counter before the first snapshot, and pass that duration to `statdiff.py` after the second snapshot. I verified the script on synthetic snapshots. A change of 100 user ticks across two seconds reports 50% of one core. ```diff -```sh +```bash pid=$(pgrep -f 'victory.exe' | head -1) cat /proc/$pid/maps > maps.txt +SECONDS=0 ./statsnap.sh $pid > before.txt ./sampler $pid 20 > samples.txt & ./offcpu.py $pid 20 offcpu.txt; wait ./statsnap.sh $pid > after.txt -./statdiff.py before.txt after.txt +./statdiff.py before.txt after.txt "$SECONDS" ```
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/236:upstream-pr/236'
git switch 'upstream-pr/236'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/236'
git switch 'upstream-pr/236'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/236'
git switch 'upstream-pr/236'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/236'
git switch 'main'
git merge --squash 'upstream-pr/236'
git switch 'main'
git merge --ff-only 'upstream-pr/236'
git switch 'main'
git merge 'upstream-pr/236'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
DexNom/VIctory!236
No description provided.