Difference between revisions of "Improving performance"
(→AMD) |
(→X11) |
||
Line 115: | Line 115: | ||
KDE Plasma (X11) with no composition appears to be a good choice. Gnome is also ok.<ref>https://www.reddit.com/r/linux_gaming/comments/cii545/linux_input_lag_analysis_v26des_windows_10_1809/</ref> You should avoid Cinnamon and Pantheon. Cinnamon requires you to completely disable composition, Pantheon has no option to disable composition at all. | KDE Plasma (X11) with no composition appears to be a good choice. Gnome is also ok.<ref>https://www.reddit.com/r/linux_gaming/comments/cii545/linux_input_lag_analysis_v26des_windows_10_1809/</ref> You should avoid Cinnamon and Pantheon. Cinnamon requires you to completely disable composition, Pantheon has no option to disable composition at all. | ||
You might want to avoid Gnome x11 if you want to use side buttons on your mouse, as this can lead to stuttering. This can be fixed, and is not an issue on Wayland<ref>https://www.reddit.com/r/linux_gaming/comments/qaxz3m/comment/hqankhn/?context=3</ref>. | |||
=== Wayland === | === Wayland === |
Revision as of 09:47, 27 October 2022
Gaming performance on Linux varies from game to game, and is very hardware dependent. Some of your games might run better than on Windows, some may run worse. But even with the same game where you would get a performance gain with one GPU you might take a performance hit with another. So it's impossible to say how your performance will compare to Windows.
BUT: Generally, you should be expecting about the same performance (±10%) as on Windows[1]. If your experience is much worse, there is probably an issue. Most Linux distributions aren't properly configured for gaming at all. Nobara is a notable exception, it already includes many of the tweaks that are mentioned here.
The good thing is, that this is very easy to change. Your performance should be OK if you do all major tweaks.
You don't have to go further if that is good enough for you and you don't want to bother reading the rest of the article. Everything else isn't as important, only situational, or might come with drawbacks. But if you still have issues, or you just want more performance, you should definitely read it. There is much that can be done to get an additional bit of performance, less input lag, less FPS drops, and significantly more performance on severely under-powered systems.
Major tweaks
These are the important tweaks, they will give a huge boost for all games. You should do all these tweaks, otherwise you will not have a good gaming experience:
- Disable composition.
- You don't need to do this if you use Gnome (the default on Pop!_OS)
- You only need to do this if you use X11.
- Use GameMode
- If they are not already installed, install the correct drivers
- You don't have to do this on Nobara or Pop!_OS.
- Do NOT download anything manually. Use the link above.
- If you have an old Nvidia card that is not supported by the current driver, look at the Nvidia specific section.
- If you don't have an Nvidia GPU, the correct drivers are probably already preinstalled. However, you won't do anything wrong if you use the guide above. On some distributions this will also give you a more recent version.
- Look at your thermals, and if they are too high, adapt the fan speed.
- There are tools to do this inside Linux, but it's probably easier to do it in the BIOS.
AMD/Nvidia specific
These tweaks are depending on what type of GPU you have. Your CPU type is not important.
AMD
It's probably worth doing, but if everything is fine and you think this is too complicated, you can ignore this section. The default values should be fine for casual gaming. If you want the maximum performance, or minimal input lag, read further.
Overclocking and controlling the GPU
You can use CoreCtrl to add performance profiles for your games, set fan speeds, and overclock/undervolt. You can also set CPU performance here, it will overrule the GameMode settings.
The default (automatic) performance profile is probably fine for most games, but it might make a big difference for some games. For example, if a game has a capped frame rate, the GPU might not clock to the highest speed which will result in sub optimal performance. Setting your GPU to high performance can yield higher FPS, or lower input lag.
Alternatively, you can also use GameMode, however this is probably a bit more complicated.
Using the correct driver
DO NOT DOWNLOAD DRIVERS WITH YOUR BROWSER. This is the "official" way, offered by AMD, but it's also the worst possible thing you can do.
There are two Vulkan drivers available for AMD GPUs: amdvlk and vulkan-radeon (RADV, MESA). The vulkan-radeon (RADV, MESA) one is the open-source version and is preferable due to better performance in most cases. It should be the one that is installed as default, so usually you would not have to do anything.
If you experience sub-par performance, you can check which driver you are using. On Arch and Ubuntu based distros (for example Manjaro, or Pop!_OS), you can check which Vulkan implementations are installed on the system with this command: ls /usr/share/vulkan/icd.d/
. It should say radeon_icd.x86_64.json
. If you have the 32bit version installed, it will (also) say radeon_icd.i686.json
. There might be others (intel for example), just be sure that there is not amd_icd64.json
. The system will use amdvlk by default if both are installed.
If you want to use amdvlk, look for instructions for your distribution. Downloading something from the AMD website should only be the last resort, if there really is no better option. There probably is a better option.
Nvidia
The Arch Wiki is a great place to start for information, but, as always, it's best to follow documentation specific to your distro.
Identify your GPU model from the Archlinux Wiki's Nvidia page as well as the GPU model/family cross-reference page and install the correct GPU release, as GPUs older than Maxwell ( are
- Use DKMS for the driver. DKMS will be necessary for using custom kernels like Zen, Xanmod or tkg with the Nvidia driver because there are no pre-packaged nvidia kernel modules for them. It also lets you update to newer kernel versions without waiting for an Nvidia driver update.[2] Every distro that has proprietary Nvidia driver support should offer a DKMS version.
- For Arch-based distributions, you may also use TKG's
nvidia-all
repo, with_dkms=""
set to true incustomization.cfg
.[3] - You may also use the nvidia-vulkan-dkms to acquire the most recent vulkan beta release with the most recent extensions.
Overclocking and controlling the GPU
- Enable coolbits in the Xorg configuration as described in the Archlinux Wiki. Specifically, setting the coolbits value to 28 on anything currently supported (post-Fermi) will enable full control over the GPU through the nvidia-settings panel (at least, as much control as you're allowed to be given).
- Use GreenWithEnvy for overclocking, setting power limits (raise or lower) and fan curves. It's the closest alternative we have to MSI Afterburner.
DLSS, RTX, Reflex features on support Nvidia GPUs (NVAPI)
The github repo for DXVK-NVAPI should be read here to fully understand what you may need to do, as the Proton version you use may necessitate certain additional steps.
- Make sure to use a Proton version of at least 6.3-6, Experimental, Proton-6.21-GE-2 (now known as GE-Proton) or Proton-tkg/wine-tkg-git of 6.17 or greater (or build your own) for DLSS, RTX, and/or Reflex on supported GPUs.
- Using the most recent Proton, Proton Experimental or GE-Proton (As of this writing on 2022-09-06) requires the following:
- Steam: use the launch options PROTON_ENABLE_NVAPI=1 DXVK_ENABLE_NVAPI=1 %command%. You may also need to add PROTON_HIDE_NVIDIA_GPU=0 for some games that do not use DXGI for detection (per the DXVK=NVAPI github README).
- For non-Steam games, use the latest Lutris or wine-ge-custom build, with Lutris, and make sure to toggle on DLSS support in the Configure -> Runner options menu.
Minor tweaks
These will not make a difference as big as the major tweaks. It might give you some FPS, or lower your input lag, but you don't have to do these tweaks if you think this is too complicated.
- Enable
Fsync
. You need to use a compatible Kernel (likezen
,tkg-pds
, orXanmod
; kernel above 5.16 is compatible with F-sync out of the box), and enable it in Lutris: Right click the game ->Configure
->Runner options
-> EnableFsync
- If you can't or don't want to install a kernel that is Fsync compatible, you can also enable Esync. The performance boost is usually not as large, though.
- Install an optimized kernel like
linux-zen
,linux-tkg-pds
, orXanmod
. This will also prevent the system from becoming unresponsive when under heavy CPU load.linux-zen
andlinux-tkg
kernels are for Arch-based distros,Xanmod
for Ubuntu-based distros. However, they should also work with other distributions, but you should always make sure to have a functioning way to update them. Don't do it if you don't know what to do if things go wrong.linux-tkg-pds
(linux-tkg with PDS scheduler) seems to perform better thanzen
[4], and has lower input lag (this is definitely noticeable in competitive shooters). Some people recommend usinglinux-tkg-bmq
(linux-tkg with BMQ scheduler) to get more consistent frame times. You can get it from chaotic AUR (list of available packages). To get all benefits you have to compile it yourself, though.- You don't need to fear that you might destroy your system. Installing a new kernel does not remove the old one. You can select the kernel you want to boot in GRUB. If things get messed up, just select your old kernel and you're fine.
Optional
These tweaks come with some drawback. You might want to apply them, but maybe only for some games.
- If you don't get enough FPS, use FSR. This might dramatically improve your framerate in GPU limited games but will definitely hurt the image quality.
- Environment variables:
DXVK_ASYNC=1
: Display frames even if they are not completely rendered. This will reduce stuttering a lot, but it could theoretically trigger anti cheat, even though this never actually happened. Your DXVK version needs to be compatible or patched to use it. Proton-GE comes with a compatible version. For Non-Steam games you can't use Proton, and need a patched DXVK-Version. For Lutris you need to copy it to~/.local/share/lutris/runtime/dxvk/
, and manually select the version inside Lutris (just type in the name manually).
- Use LatencyFleX (warning: may trigger anticheat): Similar to NVIDIA Reflex (but works with AMD and Nvidia). Lowers input lag. Manually frame capping your game (so that your GPU never exceeds 80%) should be equally good. (If you use MangoHud to do this, this might add additional input lag!)
- You might want to have a look at the extensive Arch Wiki page.
BIOS tweaks
- Above 4G Decoding (SAM / rBAR) - A BIOS option that allows the CPU to access the GPU's entire VRAM at once.
- (A-)XMP / DOCP profile - Unlocks the RAM's advertised memory speed (resulting in a faster access of the data the CPU needs).
Only AMD
- To lower your input lag even more (after doing all major and minor tweaks), you can disable page flipping (this will result in more tearing).
- This only works on X11, but if you care that much about input lag, you shouldn't use Wayland anyways.
- Create the file
/etc/X11/xorg.conf.d/20-amdgpu.conf
with content:Section "Device" Identifier "AMD" Driver "amdgpu" Option "TearFree" "false" Option "EnablePageFlip" "false" EndSection
- Environment variables:
RADV_FORCE_VRS=2x2
: Variable rate shading. This will improve performance, but reduce quality of shadows. Alternative values:2x1
or1x2
to use VRS only in one (x or y) direction[5]. (TODO: which is which?)RADV_PERFTEST=sam
: Force enable resizable bar/smart access memory. Might improve, but might as well reduce performance.RADV_DEBUG=novrsflatshading
: disable VRS for flat shading (only on GFX10.3+)RADV_PERFTEST=nggc
: enable NGGC. Can slightly improve performance on RX6000 series, but may reduce performance for other cards[6].- You may find more here: https://docs.mesa3d.org/envvars.html
Differences between Desktop Environments, and X11/Wayland
Desktop Environments may affect your performance. Your overall performance may be bad, or you might have good FPS, but high input lag.
Regarding input lag: It should be noted that we are talking about milliseconds here (the best value is 20ms, the worst is 90ms). If you are not susceptible to this (for example because you only play slow games), you may not even notice. But generally speaking, the game will feel more responsive if your input lag is low. You might also notice stuttering when the frame times are fluctuating.
X11
X11 is currently the best choice if you want minimal input lag.[7]
Generally you should be fine if you can disable composition. This is not possible in Gnome, but Gnome uses unredirection (the same thing, Windows does) instead, which is almost as good.
KDE Plasma (X11) with no composition appears to be a good choice. Gnome is also ok.[8] You should avoid Cinnamon and Pantheon. Cinnamon requires you to completely disable composition, Pantheon has no option to disable composition at all.
You might want to avoid Gnome x11 if you want to use side buttons on your mouse, as this can lead to stuttering. This can be fixed, and is not an issue on Wayland[9].
Wayland
The best way to achieve low input latency on a Wayland compositor is to enable Freesync. Currently, Sway and KDE support Freesync for AMD GPU's only. Other wlroots compositors may also support Freesync.
If you cannot enable Freesync, then you will effectively always have Vsync on, regardless of your in game settings. Vsync has seen very wide use across PC's and consoles and a majority of games ship with it enabled by default. If you already play games with Vsync enabled then you shouldn't notice much or any additional latency gaming on Wayland.
Enabling Vsync in game can cause significant additional latency if you are using a Wayland compositor without Freesync. The compositors Vsync implementation can interact with the games Vsync implementation in unpredictable ways. In general there should be no need for in game Vsync if you are using a Wayland compositor, as either Wayland or Freesync will control synchronization. Bear in mind that most games enable Vsync by default.
If you are using KDE and you have FreeSync enabled, the performance and input lag should be close to KDE X11 with composition disabled.[7] The input lag will increase by the "half frame" that is displayed with tearing. It's basically the question whether or not you want to wait for the frame to complete before displaying it.[10]
Gnome will introduce greater input lag (comparable to composition on KDE, but without the FPS problems).[10]
Troubleshooting
- Limiting FPS with MangoHud can introduce input lag. (I assume it adds one frame delay. It might as well be a bug, and only happen in specific scenarios. If you know more, why this happens, if, or how it can be avoided, please add information here.)
- You might have a distribution that uses PulseAudio instead of Pipewire. Pulseaudio introduces heavy audio delay. You should switch to Pipewire.
References and notes
- ↑ https://www.youtube.com/watch?v=Nc1mS1hxn8Q
- ↑ https://wiki.archlinux.org/title/Dynamic_Kernel_Module_Support
- ↑ https://www.reddit.com/r/linux_gaming/comments/sc9dv7/need_help_writing_wiki_article_about_how_to_tweak/hu54e1g/?context=3
- ↑ https://www.youtube.com/watch?v=qNzd57b0h08
- ↑ https://www.basnieuwenhuizen.nl/a-first-foray-into-rendering-less/
- ↑ https://www.phoronix.com/scan.php?page=article&item=radeon-radv-nggc
- ↑ 7.0 7.1 https://zamundaaa.github.io/wayland/2021/12/14/about-gaming-on-wayland.html
- ↑ https://www.reddit.com/r/linux_gaming/comments/cii545/linux_input_lag_analysis_v26des_windows_10_1809/
- ↑ https://www.reddit.com/r/linux_gaming/comments/qaxz3m/comment/hqankhn/?context=3
- ↑ 10.0 10.1 https://www.reddit.com/r/linux_gaming/comments/rghr60/about_gaming_and_latency_on_wayland/hpox61p/?context=3