Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tweaking kernel/linux for gaming
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
Saundersx
Apprentice
Apprentice


Joined: 11 Apr 2005
Posts: 290

PostPosted: Tue Jan 17, 2023 9:55 pm    Post subject: Tweaking kernel/linux for gaming Reply with quote

Thought this would be a good place to get opinions from the more seasoned linux gamers.

First off, I know GameMode (https://github.com/FeralInteractive/gamemode) exists but I still don't use systemd so it doesn't apply. I intend to cannibalize some ideas from it in the future.

I'm writing/testing a script to put my system into "gaming" mode. Here are some bits from it

set nvidia card to performance
Code:
nvidia-settings -c :0 -a "[gpu:0]/GPUPowerMizerMode=1"


increase/lock gpu cooling (used mainly to keep it from spinning up/down, for my card i set it to 55)
Code:
nvidia-settings -c :0 -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=${OC_GPU_FANS_SPEED}"


increase gpu clocks (needs more testing to find good values)
Code:
nvidia-settings -c :0 -a "[gpu:0]/GPUGraphicsClockOffset[3]=${OC_GPU_CLOCKS_OFFSET}" -a "[gpu:0]/GPUMemoryTransferRateOffset[3]=${OC_GPU_MEMORY_OFFSET}"


now this is a fun one, disable SMT. running a ryzen 3950X so have the cores to spare. another idea would be to find the "best" cores on the cpu and exclusively lock the games to those.
Code:
for cpu in $( grep -sh ',' /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | cut -d, -f2 | sort -V | uniq ); do
  echo 0 | sudo /usr/bin/tee "/sys/devices/system/cpu/cpu${cpu}/online" &>/dev/null
  # this throttling seems necessary or things crash
  sleep 0.15
done


set scaling governor to performance
Code:
for cpu in $( grep -sl ^ /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | sort -V ); do
  echo performance | sudo /usr/bin/tee "${cpu}" &>/dev/null
done


set cpu to performance
Code:
sudo /usr/bin/cpupower frequency-set -g performance


# "always" hugepages (testing, this does not universally improve things)
Code:
echo 'always' | sudo /usr/bin/tee "/sys/kernel/mm/transparent_hugepage/enabled"


and on the hardware side of things, increasing gpu voltages (currently don't use)
Code:
sudo /opt/bin/nvidia-smi -i 0 -pl "${OC_GPU_POWER_OFFSET}"


and finally since i'm running kde, disable compositor
Code:
qdbus org.kde.KWin /Compositor suspend


and if you run kde i recommend this widget https://store.kde.org/p/1297839 to control a "toggle" script. I also run irqbalance, schedtoold (gives steam a priority boost) and a custom kernel with goodies from https://github.com/sirlucjan/kernel-patches https://github.com/graysky2/linux-patches and a few other spots (I can go into this more if people want).

Interested to hear any ideas of what other people do.
Back to top
View user's profile Send private message
psycho
Guru
Guru


Joined: 22 Jun 2007
Posts: 534
Location: New Zealand

PostPosted: Wed Jan 18, 2023 4:57 am    Post subject: Reply with quote

Hi Saundersx.

You may see a drop in performance rather than a gain, with some games, if you disable SMT... I guess it depends what you're playing. Also it depends a bit on what we mean by "performance": I haven't noticed it myself, but I've heard that some games look better in benchmarks with SMT off (because their average FPS goes up), but lower minimum framerates under heavy load can result in a worse experience when the game is actually being played, despite the better-looking benchmarks. If I were doing this I think I'd leave the SMT thing out of the generic gaming mode script, and maybe just do it with specific games where it's known to help. Of course if you know it's definitely helpful for all your games, putting it into the gaming mode makes good sense.
Back to top
View user's profile Send private message
Saundersx
Apprentice
Apprentice


Joined: 11 Apr 2005
Posts: 290

PostPosted: Wed Jan 18, 2023 6:36 am    Post subject: Reply with quote

Yeah it's definitely something to play with and see. I just did a quick search and found this https://www.techspot.com/review/1882-ryzen-9-smt-on-vs-off/ which shows it depends game to game. Downside is that aside from Phoronix its hard to find out what affects linux as pretty much every gaming site, at least the technical ones with lots of benchmarks, are all windows.

One thing that peaked my interest about disabling SMT is a lot of claims that it made things "smoother". Of course these are mostly unsubstantiated claims from forum randos...
Back to top
View user's profile Send private message
steve_v
Guru
Guru


Joined: 20 Jun 2004
Posts: 388
Location: New Zealand

PostPosted: Wed Jan 18, 2023 8:22 am    Post subject: Reply with quote

psycho wrote:
You may see a drop in performance rather than a gain, with some games, if you disable SMT.

To add to that, the result is likely to vary significantly based on CPU architecture as well, as things like cache coherency (esp. on recent "chiplet" ryzens) come into play.

IME disabling SMT is definitely a "depends on your specific system & game" type suggestion, I did a bit of playing with it (among other things) a while back and the results were... inconclusive at best.
_________________
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.
Back to top
View user's profile Send private message
no101
n00b
n00b


Joined: 10 Oct 2022
Posts: 11
Location: Piney Woods

PostPosted: Wed Jan 18, 2023 9:27 pm    Post subject: Re: Tweaking kernel/linux for gaming Reply with quote

These are redundant.
Saundersx wrote:
set scaling governor to performance
Code:
for cpu in $( grep -sl ^ /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | sort -V ); do
  echo performance | sudo /usr/bin/tee "${cpu}" &>/dev/null
done


set cpu to performance
Code:
sudo /usr/bin/cpupower frequency-set -g performance



After using the echo script, try
Code:
cpupower frequency-info
and see that you're already using the performance governor.

I suppose it's just because I'm old and don't play twitchy FPS games anymore but I don't change anything to play games. I always run schedutil and things ramp up just fine. For what it's worth, I generally play strategy and indy games on AMD 3900xt + nv1070.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum