feat(perf): Send performance statistics #74
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!74
Loading…
Reference in a new issue
No description provided.
Delete branch "gab9281/LongshotLauncher:feat/perf-statistics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.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.KeepSentPerformanceStatistics), on by default and greyed out while the tick is off: each summary sent stays, exactly as sent, in the game folder'sperf_sent/, for the player to read. Off, the folder getskeep_sent=0with the tick (perf_report.py --tick on --keep-sent off), which keeps no copies and deletes those kept.--keep-sentis passed only when off, so aperf_report.pyfrom before it takes the rest as it did.LauncherService.PlayFolder, used by Play and--play),Core/PerfReports.BeforePlay:longshot_perf.iniagree 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.offalso deletes what is waiting and the copies of what was sent;perf_pending/, runsperf_report.py <folder> --sendin a process of its own, so a game that starts right away doesn't cut it short.perf_report.pyand is left as it is. A Python that won't start never stops the game from starting.LD_LIBRARY_PATH).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
d807eddon mainaacfe1c:57237ec(head0ea72a1): the build (0 warnings),tests/test_launcher_core.py --strict(1319 checks),tests/test_release.pyandscripts/translations.pypass again.dotnet build LongshotLauncher.slnx -c Release: 0 warnings, 0 errors.python -I tests/test_launcher_core.py: 1071 checks passed, includingtests/launcher_core/PerfChecks.cs(the tick, the copies setting and pending reads,ToolsFor,Planwith both settings, the commands with and without--keep-sent off, andBeforePlaywith tools that can't send).python -I tests/test_release.py: OK.python -I scripts/translations.py: all complete.--playwrotelongshot_perf.inisend=1; the game logged "performance statistics on (the launcher's Send performance statistics)";perf_pending/;--playsent it before the game started: it moved toperf_sent/, and Grafana'slongshot_perf_reports_total{result="accepted"}went 3 → 4, withlongshot_sessions_totalfor that build labelled with this PC's GPU, driver, CPU, OS and settings;d807eddwith Longshot#206 @ a401573b:--playwrotesend=1andkeep_sent=0and 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--playand 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 offis checked by Longshot#206's tests andPerfChecks.cs).Must be tested:
longshot_perf.iniwithsend=1in the folder, a summary inperf_pending\after the first close, and after the second Play that summary inperf_sent\andperf_pending\empty (Longshot#206's request T-ULGD covers the game's side).Risks
What could break: starting a game:
BeforePlayruns before every Play, but waits at most 5 s for--tickand never stops a start when Python or the script fails.Turning it off: untick it (the default); or revert.
Compatibility:
settings.jsongainssendPerformanceStatistics(false when missing). Game folders built before Longshot#206 are left as they are.Checklist
main.tests/test_launcher_core.py,tests/test_release.py,scripts/translations.py).Co-Authored-By:trailers.🤖 Generated with Claude Code
https://claude.ai/code/session_015KgSKmeEEMir1hCDFZ8BmR
a777643166f7518c602aTested 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.WIP: feat(perf): Send performance statisticsto feat(perf): Send performance statisticsd807edd: Keep a copy of what was sent, under the tick, on by default: off writeskeep_sent=0with 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.d807eddad21e003336d01e003336d00ea72a153eReviewed 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.pyand docs).The two sides agree:
perf_report.py <folder> --tick on|off [--keep-sent off]and--send,send=1/keep_sent=0inlongshot_perf.ini,perf_pending/, and the launcher'sTicked/KeptSent/Waitingparsing matches whatset_sendingwrites. 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 inperf_sent/.One thing I'd fix before merge, and one question (both inline):
BeforePlaywaits up to 5 s inPlayFolder: is that off the UI thread?Nits: the description says both 1071 and 1319 checks.
Not a blocker: two quick Plays can start two
--sendprocesses on the same folder (no lock inperf_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).
@ -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;If the player turned the tick off but this folder's own version's tools are gone (
ToolsFornull: tools let go, or a version withoutperf_report.pythat still has alongshot_perf.ini),BeforePlayreturns here and the folder keepssend=1. The game then keeps measuring and writingperf_pending/(up to 48 files) against the player's answer. Turning off needs no Python: whenonis false andTicked(folder)orWaiting(folder), deletelongshot_perf.iniandperf_pending/*.jsonandperf_sent/*.jsondirectly in C# (the same thing--tick offdoes), 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)This waits up to 5 s inside
PlayFolder.Program.cscalls 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. IsPlayalready off the UI thread? If not, run it on a worker orawaitit. 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.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
Pull request closed