run: the title's audio threads at real-time priority while it plays #149
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!149
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-149"
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?
@Arvi23 on GitHub · 2026-12-02 01:52 UTC · original
Arvi23:audio-rt→main· +237 −0 · 3 files · 1 commits · openWhat
tools/audio-rt.py, started byrun.sh playin the background, moves the game's audio threads toSCHED_RR(priority 10, below PipeWire's own) for the session.VICTORY_AUDIO_RT=0turns it off. Its log islocal/run/audio-rt-<utc>.log.Why
On a Ryzen 7 5800X3D (8 cores / 16 threads, CachyOS,
scx_beerland), the sound crackled every time the frame rate dipped below about 25 fps in the open world. Per-thread sampling of/proc/<pid>/task/*/schedstatduring play showed:memory.maxhits), so not swapping.With the mixer and its helpers at
SCHED_RR, the same thread waited 0.1 ms per second and the crackle was gone. Frame rate was unchanged: these threads use very little CPU.What it promotes
Every second it looks at the game's threads (the process of
um-play-<pid>.scopewith the most threads) and promotes:winepipewire_ti).Safety
SCHED_OTHERat once, for good. That matters where real-time throttling is off (sched_rt_runtime_usequal to the period), where a spinning real-time thread would keep its core. In testing, a title thread that went from 1% to 77% was put back within a second.ulimit -rbelow 10) it logs one line saying so and changes nothing./procand callssched_setscheduleron the game's own threads; it ends with the session (a menu restart starts a fresh one).Caveats
mainthat decoding runs on a title thread; if it is the mixer, that thread may use more than the 15% needed to be picked, and only the feeders and Wine's timer would be promoted. Logs from someone onmainwould settle it.python3(skipped if missing).🤖 Generated with Claude Code
@weneedbucks on GitHub · 2026-12-02 02:23 UTC · original · edited 2026-12-02 02:24 UTC
Your caveat mentions a branch where XApu decoding runs on a worker of its own (a similar idea to the one i filed in #137,). For context from my side (i7-10700K, RX 9060 XT, main
f7f0360): I don't get crackle, but the Opus decoding on the title thread costs frame time. In my profile that thread ran at about 70%, roughly 29% of it in XApu/Opus. Would you be open to putting that worker branch up as a separate PR? I'm happy to test it here and post before/after fps.c07227be17to8c862ac362@Arvi23 on GitHub · 2026-12-02 02:34 UTC · original
Sure, it's up on its own as #155, rebased on current main. Decoding moves to a worker per connection, results still come back in the order they were queued, and
VICTORY_APU_ASYNC=0goes back to the old path. On my 5800X3D the worker sits at 28–33% of a core in busy scenes, but I haven't done an fps A/B, so your before/after would be really useful. (I've also rebased this PR onto main after #128.)@hazre on GitHub · 2026-12-02 05:36 UTC · original
I am not sure if this is related to your fix, but I fixed the audio crackling with this patch alone.
@Arvi23 on GitHub · 2026-12-02 10:48 UTC · original
Thanks, that was it here too. On a 5800X3D / RX 9070 XT the title opened 8 short convolutions in 3 minutes of night driving (mono, 1024 frames, 40,960-float responses). With your switch at
VICTORY_DSP_PASS=0the crackle that was left is gone. It also let me dropVICTORY_AMBIENT_MOST=15, which had seemed to stop the crackle but turned the cars' headlights off at night.So there were two different crackles on this machine: the mixer starving for a core on an 8-core CPU, which this PR's real-time priority fixes, and the 5x hard-clipped pass-through, which your patch fixes. Your switch seems worth a PR of its own. The pass-through clips anything above 0.2, and phone callers are the only thing it was meant for.
@Luxuride on GitHub · 2026-12-04 12:01 UTC · original
Worth having, but not as a silent default. As it stands
VICTORY_AUDIO_RTis on by default and documented nowhere — norun.conf.defaultentry, nodocs/SETTINGS.mdrow — so a user whose audio threads behave worse underSCHED_RRhas no supported way to turn it off and the F1 menu cannot show it.tools/audio-rt.py:126,:135,:146), so a promoted thread that starts spinning stays at priority 10 for up to a second with no RT bandwidth cap. On a kernel with RT throttling off, that starves the compositor for that second — a visible hitch traded for a small crackle. A CPU budget over a shorter window would be safer.MAX_CPU_OTHERS/MAX_CPU_OURS(tools/audio-rt.py:45-46) pick threads by comm prefix and nice value, i.e. by Wine's internal naming, which is not a contract and changes between Wine versions. Keep the name-based part as the default and make the six-thread nice-based fallback opt-in.Rebase (only
README.mdconflicts), add the two doc entries, tighten the demotion window, and put the before/after numbers in the body — then it is a 30-minute review.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.