feat(perf): Send performance statistics #74

Closed
gab9281 wants to merge 2 commits from gab9281/LongshotLauncher:feat/perf-statistics into main
Member

Type: feat · Risk: low · Tested on: Linux, RTX 3060 Laptop · Needs: Windows, any GPU

Why

Longshot's performance statistics (MagicBeanDev/Longshot#206) need a place where the player says yes, and something that sends what the game wrote. Without this PR, a summary never leaves the PC.

What changed

A tick on the Settings page, off by default. Before a game starts, the launcher makes the game folder agree with it and, when it's on, sends the summaries the game left, with the folder's own nx2/perf_report.py.

  • Settings → "Send performance statistics" (App/Views/SettingsView.axaml, SettingsViewModel.SendPerformanceStatistics), off by default, with a note under it saying what is sent: the frames per area, the GPU, CPU, OS and settings. No paths, names or saves.
  • Under it, "Keep a copy of what was sent" (KeepSentPerformanceStatistics), on by default and greyed out while the tick is off: each summary sent stays, exactly as sent, in the game folder's perf_sent/, for the player to read. Off, the folder gets keep_sent=0 with the tick (perf_report.py --tick on --keep-sent off), which keeps no copies and deletes those kept. --keep-sent is passed only when off, so a perf_report.py from before it takes the rest as it did.
  • Before a game starts (LauncherService.PlayFolder, used by Play and --play), Core/PerfReports.BeforePlay:
    • makes the folder's longshot_perf.ini agree with both settings (PerfReports.Plan, KeptSent): perf_report.py <folder> --tick on|off [--keep-sent off], waited for at most 5 s, since the game reads the file when it starts. off also deletes what is waiting and the copies of what was sent;
    • with the tick on and summaries in perf_pending/, runs perf_report.py <folder> --send in a process of its own, so a game that starts right away doesn't cut it short.
  • Only the folder's own version's tools run it. A version from before the statistics has no perf_report.py and is left as it is. A Python that won't start never stops the game from starting.
  • The script runs in the game's environment (GamePlay's rule: no AppImage runtime, no LD_LIBRARY_PATH).
  • Translations: the four new texts in all 12 full catalogs; the regional ones need nothing different.

No screenshot: the tick is one more row on the Settings page, and simulated input doesn't reach the launcher's window on this PC (KDE Wayland), so it couldn't be opened on Settings for a capture.

Testing

Tested (CachyOS, KDE Wayland, RTX 3060 Laptop, .NET 10), at d807edd on main aacfe1c:

  • Rebased on main 57237ec (head 0ea72a1): the build (0 warnings), tests/test_launcher_core.py --strict (1319 checks), tests/test_release.py and scripts/translations.py pass again.
  • dotnet build LongshotLauncher.slnx -c Release: 0 warnings, 0 errors.
  • python -I tests/test_launcher_core.py: 1071 checks passed, including tests/launcher_core/PerfChecks.cs (the tick, the copies setting and pending reads, ToolsFor, Plan with both settings, the commands with and without --keep-sent off, and BeforePlay with tools that can't send). python -I tests/test_release.py: OK. python -I scripts/translations.py: all complete.
  • End to end, in the game, with Longshot#206 @ 9981a39a (on main e090cc48, v3.0.0-rc.4), a stand-in launcher home with the setting on, against the deployed telemetry service:
    • --play wrote longshot_perf.ini send=1; the game logged "performance statistics on (the launcher's Send performance statistics)";
    • closed with the window's close: a summary in perf_pending/;
    • the next --play sent it before the game started: it moved to perf_sent/, and Grafana's longshot_perf_reports_total{result="accepted"} went 3 → 4, with longshot_sessions_total for that build labelled with this PC's GPU, driver, CPU, OS and settings;
    • once more: accepted 4 → 5, sessions 1 → 2.
  • Keep a copy of what was sent off, at d807edd with Longshot#206 @ a401573b: --play wrote send=1 and keep_sent=0 and deleted the 3 copies kept before; the game still logged "performance statistics on"; quit through the control bridge, its summary was sent at the next --play and no copy was kept.

Not tested: Windows (this PC is Linux only); a Flatpak launcher; the Settings page with the new tick on screen (no screenshot: simulated input can't open it on this PC); ticking it off on screen (--tick off is checked by Longshot#206's tests and PerfChecks.cs).

Must be tested:

  • Windows, any GPU: with a game folder built from Longshot#206, tick Send performance statistics, Play, close the game after a few minutes, then Play again, expecting longshot_perf.ini with send=1 in the folder, a summary in perf_pending\ after the first close, and after the second Play that summary in perf_sent\ and perf_pending\ empty (Longshot#206's request T-ULGD covers the game's side).

Risks

What could break: starting a game: BeforePlay runs before every Play, but waits at most 5 s for --tick and never stops a start when Python or the script fails.

Turning it off: untick it (the default); or revert.

Compatibility: settings.json gains sendPerformanceStatistics (false when missing). Game folders built before Longshot#206 are left as they are.

Checklist

  • One topic.
  • The title is a Conventional Commit.
  • Rebased on current main.
  • The launcher's checks pass (tests/test_launcher_core.py, tests/test_release.py, scripts/translations.py).
  • No game files or anything made from them.
  • The license is OK: GPL-3.0-or-later, all new code.
  • AI assistance recorded with Co-Authored-By: trailers.
  • Tested in the game (Linux), end to end with Longshot#206.
  • Tested in the game (Linux), end to end with Longshot#206; Windows is in Must be tested, with Longshot#206's request T-ULGD.

🤖 Generated with Claude Code

https://claude.ai/code/session_015KgSKmeEEMir1hCDFZ8BmR

**Type:** feat · **Risk:** low · **Tested on:** Linux, RTX 3060 Laptop · **Needs:** Windows, any GPU ## Why Longshot's performance statistics (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/206) need a place where the player says yes, and something that sends what the game wrote. Without this PR, a summary never leaves the PC. ## What changed A tick on the Settings page, off by default. Before a game starts, the launcher makes the game folder agree with it and, when it's on, sends the summaries the game left, with the folder's own `nx2/perf_report.py`. - **Settings → "Send performance statistics"** (`App/Views/SettingsView.axaml`, `SettingsViewModel.SendPerformanceStatistics`), off by default, with a note under it saying what is sent: the frames per area, the GPU, CPU, OS and settings. No paths, names or saves. - **Under it, "Keep a copy of what was sent"** (`KeepSentPerformanceStatistics`), on by default and greyed out while the tick is off: each summary sent stays, exactly as sent, in the game folder's `perf_sent/`, for the player to read. Off, the folder gets `keep_sent=0` with the tick (`perf_report.py --tick on --keep-sent off`), which keeps no copies and deletes those kept. `--keep-sent` is passed only when off, so a `perf_report.py` from before it takes the rest as it did. - **Before a game starts** (`LauncherService.PlayFolder`, used by Play and `--play`), `Core/PerfReports.BeforePlay`: - makes the folder's `longshot_perf.ini` agree with both settings (`PerfReports.Plan`, `KeptSent`): `perf_report.py <folder> --tick on|off [--keep-sent off]`, waited for at most 5 s, since the game reads the file when it starts. `off` also deletes what is waiting and the copies of what was sent; - with the tick on and summaries in `perf_pending/`, runs `perf_report.py <folder> --send` in a process of its own, so a game that starts right away doesn't cut it short. - **Only the folder's own version's tools run it.** A version from before the statistics has no `perf_report.py` and is left as it is. A Python that won't start never stops the game from starting. - The script runs in the game's environment (GamePlay's rule: no AppImage runtime, no `LD_LIBRARY_PATH`). - **Translations:** the four new texts in all 12 full catalogs; the regional ones need nothing different. No screenshot: the tick is one more row on the Settings page, and simulated input doesn't reach the launcher's window on this PC (KDE Wayland), so it couldn't be opened on Settings for a capture. ## Testing **Tested** (CachyOS, KDE Wayland, RTX 3060 Laptop, .NET 10), at d807edd on main aacfe1c: - Rebased on main 57237ec (head 0ea72a1): the build (0 warnings), `tests/test_launcher_core.py --strict` (1319 checks), `tests/test_release.py` and `scripts/translations.py` pass again. - `dotnet build LongshotLauncher.slnx -c Release`: 0 warnings, 0 errors. - `python -I tests/test_launcher_core.py`: 1071 checks passed, including `tests/launcher_core/PerfChecks.cs` (the tick, the copies setting and pending reads, `ToolsFor`, `Plan` with both settings, the commands with and without `--keep-sent off`, and `BeforePlay` with tools that can't send). `python -I tests/test_release.py`: OK. `python -I scripts/translations.py`: all complete. - **End to end, in the game**, with Longshot#206 @ 9981a39a (on main e090cc48, v3.0.0-rc.4), a stand-in launcher home with the setting on, against the deployed telemetry service: - `--play` wrote `longshot_perf.ini` `send=1`; the game logged "performance statistics on (the launcher's Send performance statistics)"; - closed with the window's close: a summary in `perf_pending/`; - the next `--play` sent it before the game started: it moved to `perf_sent/`, and Grafana's `longshot_perf_reports_total{result="accepted"}` went 3 → 4, with `longshot_sessions_total` for that build labelled with this PC's GPU, driver, CPU, OS and settings; - once more: accepted 4 → 5, sessions 1 → 2. - **Keep a copy of what was sent off**, at d807edd with Longshot#206 @ a401573b: `--play` wrote `send=1` and `keep_sent=0` and deleted the 3 copies kept before; the game still logged "performance statistics on"; quit through the control bridge, its summary was sent at the next `--play` and no copy was kept. **Not tested:** Windows (this PC is Linux only); a Flatpak launcher; the Settings page with the new tick on screen (no screenshot: simulated input can't open it on this PC); ticking it off on screen (`--tick off` is checked by Longshot#206's tests and `PerfChecks.cs`). **Must be tested:** - Windows, any GPU: with a game folder built from Longshot#206, tick Send performance statistics, Play, close the game after a few minutes, then Play again, expecting `longshot_perf.ini` with `send=1` in the folder, a summary in `perf_pending\` after the first close, and after the second Play that summary in `perf_sent\` and `perf_pending\` empty (Longshot#206's request T-ULGD covers the game's side). ## Risks **What could break:** starting a game: `BeforePlay` runs before every Play, but waits at most 5 s for `--tick` and never stops a start when Python or the script fails. **Turning it off:** untick it (the default); or revert. **Compatibility:** `settings.json` gains `sendPerformanceStatistics` (false when missing). Game folders built before Longshot#206 are left as they are. ## Checklist - [x] One topic. - [x] The title is a Conventional Commit. - [x] Rebased on current `main`. - [x] The launcher's checks pass (`tests/test_launcher_core.py`, `tests/test_release.py`, `scripts/translations.py`). - [x] No game files or anything made from them. - [x] The license is OK: GPL-3.0-or-later, all new code. - [x] AI assistance recorded with `Co-Authored-By:` trailers. - [x] Tested in the game (Linux), end to end with Longshot#206. - [x] Tested in the game (Linux), end to end with Longshot#206; Windows is in Must be tested, with Longshot#206's request T-ULGD. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015KgSKmeEEMir1hCDFZ8BmR
feat(perf): Send performance statistics
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 13s
a777643166
A tick on the Settings page, off by default, for Longshot's performance statistics
(MagicBeanDev/Longshot#206). Before a game starts, the launcher makes the folder's
longshot_perf.ini agree with it (perf_report.py --tick on|off, waited for at most
5 s) and, with it on, sends what the game left in perf_pending/ (perf_report.py
--send, in a process of its own). Only the folder's own version's tools run it, and
a version without perf_report.py is left as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015KgSKmeEEMir1hCDFZ8BmR
gab9281 force-pushed feat/perf-statistics from a777643166
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 13s
to f7518c602a
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 15s
2026-11-15 04:46:21 +00:00
Compare
Author
Member

Tested end to end in the game with Longshot#206 @ 9981a39a (rebased on main e090cc48, now ready for review): the tick wrote send=1, the game wrote a summary at close, and the next Play sent it to the deployed telemetry service (Grafana: accepted 3 → 5 over two sends, the sessions labelled with this PC's hardware). The description is rewritten with the results; Windows still needs a tester.

Tested end to end in the game with Longshot#206 @ 9981a39a (rebased on main e090cc48, now ready for review): the tick wrote `send=1`, the game wrote a summary at close, and the next Play sent it to the deployed telemetry service (Grafana: accepted 3 → 5 over two sends, the sessions labelled with this PC's hardware). The description is rewritten with the results; Windows still needs a tester.
feat(perf): Keep a copy of what was sent
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
d807eddad2
Under Send performance statistics, a second tick, on by default: each summary
sent is kept as sent in the game folder's perf_sent/, for the player to read.
Off, the launcher writes keep_sent=0 with the tick (perf_report.py --tick on
--keep-sent off, Longshot#206), which keeps no more copies and deletes those
kept. --keep-sent is passed only when off, so a perf_report.py from before it
takes the rest as it did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015KgSKmeEEMir1hCDFZ8BmR
gab9281 changed title from WIP: feat(perf): Send performance statistics to feat(perf): Send performance statistics 2026-11-15 06:22:34 +00:00
Author
Member

d807edd: Keep a copy of what was sent, under the tick, on by default: off writes keep_sent=0 with the tick (Longshot#206's --keep-sent off), which keeps no copies and deletes those kept. Tested end to end with Longshot#206 @ a401573b. 1071 core checks, 0 warnings, translations complete. Out of WIP, with Longshot#206 ready for review; Windows stays in Must be tested.

d807edd: **Keep a copy of what was sent**, under the tick, on by default: off writes `keep_sent=0` with the tick (Longshot#206's `--keep-sent off`), which keeps no copies and deletes those kept. Tested end to end with Longshot#206 @ a401573b. 1071 core checks, 0 warnings, translations complete. Out of WIP, with Longshot#206 ready for review; Windows stays in Must be tested.
gab9281 force-pushed feat/perf-statistics from d807eddad2
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
to 1e003336d0
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
2026-11-15 18:28:37 +00:00
Compare
gab9281 force-pushed feat/perf-statistics from 1e003336d0
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
to 0ea72a153e
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
2026-11-15 19:32:20 +00:00
Compare
HumanBean left a comment

Reviewed the code only (no tests or builds run; read the PR comments, the end-to-end run on Linux, and Longshot's MagicBeanDev/Longshot#206 nx2/perf_report.py and docs).

The two sides agree: perf_report.py <folder> --tick on|off [--keep-sent off] and --send, send=1 / keep_sent=0 in longshot_perf.ini, perf_pending/, and the launcher's Ticked/KeptSent/Waiting parsing matches what set_sending writes. Privacy is good: off by default, the text says what is sent, nothing is sent by the launcher itself, the summary carries no ID, no paths or names, and the copies are readable in perf_sent/.

One thing I'd fix before merge, and one question (both inline):

  1. Turning it off isn't honoured when the folder's tools are gone.
  2. BeforePlay waits up to 5 s in PlayFolder: is that off the UI thread?

Nits: the description says both 1071 and 1319 checks.

Not a blocker: two quick Plays can start two --send processes on the same folder (no lock in perf_report.py), so a summary could be sent and counted twice; that is Longshot's side, worth a line on MagicBeanDev/Longshot#206.

Windows is untested (the description says so and keeps it under Must be tested).

Reviewed the code only (no tests or builds run; read the PR comments, the end-to-end run on Linux, and Longshot's https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/206 `nx2/perf_report.py` and docs). The two sides agree: `perf_report.py <folder> --tick on|off [--keep-sent off]` and `--send`, `send=1` / `keep_sent=0` in `longshot_perf.ini`, `perf_pending/`, and the launcher's `Ticked`/`KeptSent`/`Waiting` parsing matches what `set_sending` writes. Privacy is good: off by default, the text says what is sent, nothing is sent by the launcher itself, the summary carries no ID, no paths or names, and the copies are readable in `perf_sent/`. One thing I'd fix before merge, and one question (both inline): 1. Turning it off isn't honoured when the folder's tools are gone. 2. `BeforePlay` waits up to 5 s in `PlayFolder`: is that off the UI thread? Nits: the description says both 1071 and 1319 checks. Not a blocker: two quick Plays can start two `--send` processes on the same folder (no lock in `perf_report.py`), so a summary could be sent and counted twice; that is Longshot's side, worth a line on https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/206. Windows is untested (the description says so and keeps it under Must be tested).
@ -0,0 +78,4 @@
{
var plan = Plan(on, keep, Ticked(folder), KeptSent(folder), Waiting(folder));
if (plan.Tick == null && !plan.Send) return;
if (ToolsFor(folder, tools) is not { } mine) return;
Owner

If the player turned the tick off but this folder's own version's tools are gone (ToolsFor null: tools let go, or a version without perf_report.py that still has a longshot_perf.ini), BeforePlay returns here and the folder keeps send=1. The game then keeps measuring and writing perf_pending/ (up to 48 files) against the player's answer. Turning off needs no Python: when on is false and Ticked(folder) or Waiting(folder), delete longshot_perf.ini and perf_pending/*.json and perf_sent/*.json directly in C# (the same thing --tick off does), and use the script only for the on direction. A check in PerfChecks for 'off, no tools, ticked folder: the ini is gone' would cover it.

If the player turned the tick off but this folder's own version's tools are gone (`ToolsFor` null: tools let go, or a version without `perf_report.py` that still has a `longshot_perf.ini`), `BeforePlay` returns here and the folder keeps `send=1`. The game then keeps measuring and writing `perf_pending/` (up to 48 files) against the player's answer. Turning off needs no Python: when `on` is false and `Ticked(folder)` or `Waiting(folder)`, delete `longshot_perf.ini` and `perf_pending/*.json` and `perf_sent/*.json` directly in C# (the same thing `--tick off` does), and use the script only for the on direction. A check in PerfChecks for 'off, no tools, ticked folder: the ini is gone' would cover it.
@ -0,0 +84,4 @@
if (plan.Tick is { } tick)
{
using var p = Process.Start(TickCommand(mine, folder, tick, keep));
if (p != null && !p.WaitForExit(5000)) return; // (a stuck one is left; the game starts with the tick as it was)
Owner

This waits up to 5 s inside PlayFolder. Program.cs calls it for --play, and Play from the window calls it too: if it runs on the UI thread, a slow Python start (cold disk, antivirus on Windows) freezes the window for up to 5 s before the game starts. Is Play already off the UI thread? If not, run it on a worker or await it. Also the 5 s timeout leaves the child running: on a timeout the game starts with the old tick and the tick lands later, so the game that starts may not match the player's answer for that run (either direction, including an unticked folder measuring one more session). Fine as a rare case, but worth saying in the comment.

This waits up to 5 s inside `PlayFolder`. `Program.cs` calls it for `--play`, and Play from the window calls it too: if it runs on the UI thread, a slow Python start (cold disk, antivirus on Windows) freezes the window for up to 5 s before the game starts. Is `Play` already off the UI thread? If not, run it on a worker or `await` it. Also the 5 s timeout leaves the child running: on a timeout the game starts with the old tick and the tick lands later, so the game that starts may not match the player's answer for that run (either direction, including an unticked folder measuring one more session). Fine as a rare case, but worth saying in the comment.
Author
Member

Closing: this is merged into #128, which carries both of its commits rebased on main, with the conflicts with Download updates early and the translations resolved. #128 also adds build summaries and the Send crash reports automatically tick. The game's side is MagicBeanDev/Longshot#983. Please review the statistics there.

🤖 Generated with Claude Code

Closing: this is merged into #128, which carries both of its commits rebased on main, with the conflicts with Download updates early and the translations resolved. #128 also adds build summaries and the Send crash reports automatically tick. The game's side is MagicBeanDev/Longshot#983. Please review the statistics there. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gab9281 closed this pull request 2026-11-16 18:39:50 +00:00
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s

Pull request closed

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/LongshotLauncher!74
No description provided.