high priority - renice/ionice app at startup (Winamp, audio)

Questions about Wine on Linux
Locked
User avatar
Maniaxx
Level 2
Level 2
Posts: 38
Joined: Sun Aug 20, 2017 5:42 pm

high priority - renice/ionice app at startup (Winamp, audio)

Post by Maniaxx »

Hallo,
i'm running Winamp on Wine 2.15. It works properly mostly but sometimes when there's higher disk i/o or cpu usage on the system there are short audio dropouts or distortions.

So i want to try to raise cpu and i/o priority (renice, ionice) of all wine processes. What's the best way to achieve this? The Winamp process has a dynamic name and PIDs are always different so i'm not sure how to properly target the processes with a pre-script in q4wine.

Any ideas?

Linux 4.12.8-2-ARCH x86_64 GNU/Linux
wine v2.15
q4wine 1.3.5
Winamp v5.666 Build 3516
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Bob Wya »

@Maniaxx,

Take a look at the Wine Staging Wiki : Environment Variables ...
Specifically the section on Realtime Priorities ...

Bob
User avatar
Maniaxx
Level 2
Level 2
Posts: 38
Joined: Sun Aug 20, 2017 5:42 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Maniaxx »

Thanks, i've changed my prefix in q4wine to:

Code: Select all

%CONSOLE_BIN% %CONSOLE_ARGS% %ENV_BIN% STAGING_RT_PRIORITY_SERVER=90 STAGING_RT_PRIORITY_BASE=90 %ENV_ARGS% /bin/sh -c "%WORK_DIR% %SET_NICE% %WINE_BIN% %VIRTUAL_DESKTOP% %PROGRAM_BIN% %PROGRAM_ARGS% 2>&1 "
and priority is 90 when i start Winamp in q4wine.

But when i double-click a mp3,mod,xm directly in Thunar/XFCE priority is not overridden.
Any idea how i can get it up there as well? Its a mime-type that was set up by Wine itself (i guess).
User avatar
Maniaxx
Level 2
Level 2
Posts: 38
Joined: Sun Aug 20, 2017 5:42 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Maniaxx »

It doesn't help though. RTPRIO is 90 but drop-outs are still there on high i/o. I probably do need ionice.
Any idea how to do that?
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Bob Wya »

Maniaxx wrote:...

But when i double-click a mp3,mod,xm directly in Thunar/XFCE priority is not overridden.
Any idea how i can get it up there as well? Its a mime-type that was set up by Wine itself (i guess).
This command will find all the current Mime-type Wine associations for your Linux Desktop:

Code: Select all

find "${HOME}/.local/share/applications/" -type f -name "wine-extension*.desktop"
Just edit the files you want to change.

You might want to disable winemenubuilder.exe to stop Wine overwriting these Mime files.
E.g. when installing new stuff (in any WINEPREFIX):

Code: Select all

WINEDLLOVERRIDES=winemenubuilder.exe=d wine setup.exe
Bob
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Bob Wya »

Maniaxx wrote:It doesn't help though. RTPRIO is 90 but drop-outs are still there on high i/o. I probably do need ionice.
Any idea how to do that?
You've confirmed that the wine-server process priority is altered? Say with: ps or htop ?

If the priority is really applied then it sounds more like a kernel scheduler issue - processes are getting "too long" CPU time slices.
Have you tried a more interactive kernel scheduler? MQ or BFQ say?

ionice isn't going to help Wine / winamp... That should be fairly obvious...
You might benefit from ionice'ing Thunar!

Bob
User avatar
Maniaxx
Level 2
Level 2
Posts: 38
Joined: Sun Aug 20, 2017 5:42 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Maniaxx »

Bob Wya wrote:[...]Mime-type Wine associations for your Linux Desktop[...]
Just edit the files you want to change.
The 'wine-extension-mp3.desktop' looks like this:

Code: Select all

[Desktop Entry]
Type=Application
Name=Winamp
MimeType=audio/mpeg;
Exec=env WINEPREFIX="/home/user/.wine" wine start /ProgIDOpen Winamp.File.MP3 %f
NoDisplay=true
StartupNotify=true
Icon=F465_winamp.0
And it results in this process tree (started with Thunar. No RTPRIO will be set.):

Code: Select all

user     13478     1 ?        /usr/bin/wineserver
user     13484     1 ?        C:\windows\system32\services.exe
user     13486     1 ?        C:\windows\system32\explorer.exe /desktop
user     13489     1 ?        C:\windows\system32\winedevice.exe
user     13498     1 ?        C:\windows\system32\plugplay.exe
user     13504     1 ?        C:\windows\system32\winedevice.exe
user     13516     1 ?        C:\Program Files (x86)\Winamp\winamp.exe Z:\media\Volume-F\MP3-E\Eric.mp3
When started with q4wine shortcut (RTPRIO gets properly set):

Code: Select all

user     13563     1 ?        /usr/bin/q4wine-helper --prefix Default --nice 0 --program-bin /home/user/.wine/drive_c/Program Files (x86)/Winamp/winamp.exe --wrkdir /home/user/.wine/drive_c/Program Files (x86)/Winamp/
user     13565 13563 ?        /bin/sh -c cd '/home/user/.wine/drive_c/Program Files (x86)/Winamp/' &&  STAGING_RT_PRIORITY_SERVER=90  '/usr/bin/wine'   'winamp.exe'  2>&1 
user     13566 13565 ?        winamp.exe
user     13569     1 ?        /usr/bin/wineserver
user     13575     1 ?        C:\windows\system32\services.exe
user     13578     1 ?        C:\windows\system32\explorer.exe /desktop
user     13580     1 ?        C:\windows\system32\winedevice.exe
user     13590     1 ?        C:\windows\system32\plugplay.exe
user     13596     1 ?        C:\windows\system32\winedevice.exe
Its one and the same prefix and the MIME-type explicitly points to the prefix 'Exec=env WINEPREFIX="/home/user/.wine"[...]'. Isn't that already correct? Edit: On the other hand... i guess the altered custom cmdline i set in q4wine is not part of the wineprefix itself. Then it makes sense.
Bob Wya wrote:You've confirmed that the wine-server process priority is altered? Say with: ps or htop ?
Yes, i check with:

Code: Select all

ps ax --format uname,pid,ppid,tty,cmd,cls,pri,rtprio
Bob Wya wrote:Have you tried a more interactive kernel scheduler? MQ or BFQ say?
I only have 'noop deadline [cfq]' in the standard kernel. They say some system background services rely on CFQ priorities so it probably wouldn't be a good solution in the long run.
Bob Wya wrote:ionice isn't going to help Wine / winamp... That should be fairly obvious...
You might benefit from ionice'ing Thunar!
I thought instead of lowering "all others" i better raise wine. Who knows what other programs might create high I/O as well (ftp, samba, games...). But i will try that next.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: high priority - renice/ionice app at startup (Winamp, au

Post by Bob Wya »

I'm using the MQ variant of the Deadline scheduler...
MQ Deadline Kernel Scheduler.png
That's worth a shot!

I also go for a 1000 HZ Preemtible (Low-Latency Desktop) Kernel config.

Code: Select all

uname -r
4.12.8-gentoo
It's BS that you need CFQ (unless you're running a server)!
Your background processes will continue to run fine - they'll just not get huge slices of disk I/O time.

If you try to run a more stock Kernel setup with Gentoo - your DE grinds to a halt when you're compiling lots of packages... :cry:

For your Wine Mime-type desktop entry example - you'd want:

Code: Select all

[Desktop Entry]
Type=Application
Name=Winamp
MimeType=audio/mpeg;
Exec=env STAGING_RT_PRIORITY_SERVER=90 STAGING_RT_PRIORITY_BASE=90 WINEPREFIX="/home/user/.wine" wine start /ProgIDOpen Winamp.File.MP3 %f
NoDisplay=true
StartupNotify=true
Icon=F465_winamp.0
Bob
Locked