FeralInteractive / gamemode

Optimise Linux system performance on demand
BSD 3-Clause "New" or "Revised" License
4.64k stars 183 forks source link

7900X3D core pinning is reducing FPS and core parking does not work #453

Closed mhmarf closed 3 weeks ago

mhmarf commented 8 months ago

Hello and thank you a lot for your work.

Describe the bug I'm not sure this is a gamemode (1.8.1) bug or Linux Kernel does not really support 7900x3d, but pin_cores is resulting in fewer FPS and park_cores is not even working. lstopo: topo

Tested on Horizon Zero Dawn 720p resolution and lowest possible settings and same scene while looking at the ground: /usr/share/gamemode/gamemode.ini -> pin_cores=yes: 265 FPS core_pin

park_cores=yes: does not work (mangohud shows all cores are working) 350 FPS core_park

gamemode disabled (via lutris): 350 FPS gamemode off

(BTW playing on 1440p resolution and high graphics settings, core pinning does not reduce fps. I just wanted to make the game cpu bound by playing 720p to see what will happen...)

To Reproduce Steps used to reproduce the behavior:

  1. Enable gamemod with Lutris (using default gamemode.ini pin_cores=yes option).
  2. Run Horizon Zero Dawn on 720p resolution.
  3. FPS decreases.
  4. use park_cores=yes
  5. all cores are active.

Expected behavior FPS is supposed to increase (though not sure if Linux fully supports 3D V-cache on kernel level...) and park_cores=yes should disable cores with no 3d v-cache.

System Info (please complete the following information):

mhmarf commented 8 months ago

I just tested on Remnant 2 and core pinning did NOT reduce fps at all but gave same fps as gamemode off... yet core parking still did not work.

dux1chuanl commented 6 months ago

interested in this issue. As I know, AMD is pushing X3D CPU kernel driver to the latest Linux kernel. In this link: https://lore.kernel.org/linux-pm/CAJZ5v0gzKdjZJBypEw1+czGN-SHbx0s0-h=Lq96+MDVAO11PYQ@mail.gmail.com/

@mhmarf

mhmarf commented 4 weeks ago

Hello again! Updating this after 7 months! I tested core pinning and core parking capabilities of gamemode 1.8.1 again on CachyOS 6.9.2 and also today on newly released Linux Mint 22 Wilma (which comes with kernel 6.8 and also default gamemode 1.8.1-2 BTW which is very nice!).

On CachyOS 6.9.2 surprisingly core_pinning=yes resulted in better performance of the games tested than original Nobara 38 but nowhere close to when disabling entire CCD1 (CCD with no extra v-cache) through BIOS! That resulted in MUCH more performance gain than core pinning. Later on I discovered I can disabled the entire CCD1 inside Linux and no need to go to BIOS by using HotPlug (thanks to CachyOS dev ptr1337 who told me this):

echo 0 > /sys/devices/system/cpu/cpu6/online
echo 0 > /sys/devices/system/cpu/cpu7/online
...
echo 0 > /sys/devices/system/cpu/cpu23/online

and so on... needless to say core_parking=yes also did not work on CachyOS either...

But today I have managed to finally make Core Parking feature of Gamemode work which gave me equivalent performance of disabling CCD1!! After googling for 30 seconds (:D) I realized there is a polkit rule for gamemode located: /usr/share/polkit-1/rules.d/gamemode.rules

/*
 * Allow users in privileged gamemode group to run cpugovctl &
 * gpuclockctl without authentication
 */
polkit.addRule(function (action, subject) {
    if ((action.id == "com.feralinteractive.GameMode.governor-helper" ||
         action.id == "com.feralinteractive.GameMode.gpu-helper" ||
         action.id == "com.feralinteractive.GameMode.cpu-helper" ||
         action.id == "com.feralinteractive.GameMode.procsys-helper") &&
        subject.isInGroup("gamemode"))
    {
        return polkit.Result.YES;
    }
});

I replaced "gamemode" in subject.isInGroup("gamemode") with my user name (which can be known using whoami command) and core parking is working now! Wow!

Here is a benchmark of Outer Wilds (960x540 resolution) on Linux Mint 22 Wilma (7900X3D): Gamemode off: 900 FPS no gamemode

Gamemode Core Pinning: 916 FPS corepinning

Gamemode Core Parking (notice how non v-cache cores no longer exist!!): 1300 FPS parkcontrol (BTW notice that mangohud is wrongly saying gamemode is off which is not true...)

To summarize, on 7900X3D, core pinning performance gain is minimal and not worth it, instead use core parking (/usr/share/gamemode/gamemode.ini -> core_parking=yes) but to make it work you need to edit /usr/share/polkit-1/rules.d/gamemode.rules as said above!

Thank you Feral Interactive!

mhmarf commented 4 weeks ago

I reopened and leave it to gamemode devs to maybe check it to see if they want to make any changes to their code and close this as completed themselves...

rivenirvana commented 4 weeks ago

I replaced "gamemode" in subject.isInGroup("gamemode") with my user name (which can be known using whoami command) and core parking is working now! Wow!

Have you made sure to add your user to the gamemode group? I don't think this rule edit is necessary if you have done so.

mhmarf commented 4 weeks ago

I replaced "gamemode" in subject.isInGroup("gamemode") with my user name (which can be known using whoami command) and core parking is working now! Wow!

Have you made sure to add your user to the gamemode group? I don't think this rule edit is necessary if you have done so.

Eh... I just did and it worked lol... how was I supposed to know this? I didn't even know gamemode is a group as it never showed when using groups command... For fellow clueless gamers here's how to do this (took me another 30 seconds google search...): sudo gpasswd -a YOURUSERNAME gamemode Thank you!

rivenirvana commented 3 weeks ago

Eh... I just did and it worked lol... how was I supposed to know this? I didn't even know gamemode is a group as it never showed when using groups command... For fellow clueless gamers here's how to do this (took me another 30 seconds google search...): sudo gpasswd -a YOURUSERNAME gamemode Thank you!

Yknow what, I don't actually know where I first heard/saw/read about that as well. I can recall having seen multiple posts & discussions about it in passing, but that was already after the fact.

I checked just now and I think the only reference for it in the repo is in a very subtle comment in example/gamemode.ini. Since this seems to be an essential step in the installation process to make sure that gamemode is set up properly and that all its features are usable, it might be worthwhile to make a PR and include this information in the main README, or even get interactively prompted for it in bootstrap.sh.

mhmarf commented 3 weeks ago

I just did it... https://github.com/FeralInteractive/gamemode/pull/490..