Difference between revisions of "Improving performance"

From Linux Gaming
Jump to navigation Jump to search
Line 32: Line 32:


*Use [https://github.com/ishitatsuyuki/LatencyFleX 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!)
*Use [https://github.com/ishitatsuyuki/LatencyFleX 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!)
* Environment variables:  
* [[Environment variables]]:  
**<code>DXVK_ASYNC=1</code>: Display frames even if they are not completely rendered. This will reduce stuttering a lot, but might trip anti cheat! Your wine version needs to be compatible or patched to use it. Proton-GE is compatible.
**<code>DXVK_ASYNC=1</code>: Display frames even if they are not completely rendered. This will reduce stuttering a lot, but might trip anti cheat! Your wine version needs to be compatible or patched to use it. Proton-GE is compatible.
**Only AMD:
***<code>RADV_FORCE_VRS=2x2</code>: Variable rate shading. This will improve performance, but reduce quality of shadows. Alternative values: <code>2x1</code> or <code>1x2</code> to use VRS only in one (x or y) direction<ref>https://www.basnieuwenhuizen.nl/a-first-foray-into-rendering-less/</ref>. (TODO: which is which?)
***<code>RADV_PERFTEST=sam</code>: Force enable resizable bar/smart access memory. Might improve, but might as well reduce performance.
***<code>RADV_DEBUG=novrsflatshading</code>: disable VRS for [https://graphics.fandom.com/wiki/Flat_shading flat shading] (only on GFX10.3+)
***<code>RADV_PERFTEST=nggc</code>: enable NGGC. Can slightly improve performance on RX6000 series, but may reduce performance for other cards<ref>https://www.phoronix.com/scan.php?page=article&item=radeon-radv-nggc</ref>.
***You may find more here: https://docs.mesa3d.org/envvars.html
*You might want to have a look at the extensive [https://wiki.archlinux.org/title/Gaming#Improving_performance Arch Wiki page].
*You might want to have a look at the extensive [https://wiki.archlinux.org/title/Gaming#Improving_performance Arch Wiki page].


Line 58: Line 52:
*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 (even tho your mileage may vary). If you experience sub-par performance, check which driver you are using.
*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 (even tho your mileage may vary). If you experience sub-par performance, check which driver you are using.
** To check which Vulkan implementations are installed on system use this command (system will use amdvlk by default if both are installed): <code>ls /usr/share/vulkan/icd.d/</code>. It should say <code>radeon_icd.x86_64.json</code>. If you have the 32bit version installed, it will (also) say <code>radeon_icd.i686.json</code>. There might be others (intel for example), just be sure that there is not <code>amd_icd64.json</code>.
** To check which Vulkan implementations are installed on system use this command (system will use amdvlk by default if both are installed): <code>ls /usr/share/vulkan/icd.d/</code>. It should say <code>radeon_icd.x86_64.json</code>. If you have the 32bit version installed, it will (also) say <code>radeon_icd.i686.json</code>. There might be others (intel for example), just be sure that there is not <code>amd_icd64.json</code>.
*[[Environment variables]]:
**<code>RADV_FORCE_VRS=2x2</code>: Variable rate shading. This will improve performance, but reduce quality of shadows. Alternative values: <code>2x1</code> or <code>1x2</code> to use VRS only in one (x or y) direction<ref>https://www.basnieuwenhuizen.nl/a-first-foray-into-rendering-less/</ref>. (TODO: which is which?)
**<code>RADV_PERFTEST=sam</code>: Force enable resizable bar/smart access memory. Might improve, but might as well reduce performance.
**<code>RADV_DEBUG=novrsflatshading</code>: disable VRS for [https://graphics.fandom.com/wiki/Flat_shading flat shading] (only on GFX10.3+)
**<code>RADV_PERFTEST=nggc</code>: enable NGGC. Can slightly improve performance on RX6000 series, but may reduce performance for other cards<ref>https://www.phoronix.com/scan.php?page=article&item=radeon-radv-nggc</ref>.
**You may find more here: https://docs.mesa3d.org/envvars.html
===Nvidia===
===Nvidia===
{{Needs work|Problem=not complete, and most is just copied from a reddit post}}
{{Needs work|Problem=not complete, and most is just copied from a reddit post}}

Revision as of 22:23, 30 March 2022

Game performance on Linux varies from game to game. Some games run better than on Windows, some run worse. Generally, you should be expecting about the same performance (±5%). If your experience is much worse, there is probably an issue. But even if your performance is already good, you might be able to get an even better experience - maybe even significantly better than on Windows (depending on the game, and on the hardware).

Major tweaks

This will give a huge boost for all games. You should do all these tweaks, otherwise you will not have a good gaming experience:

Minor tweaks

This 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 (like zen, tkg-pds, or Xanmod; 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 -> Enable Fsync
    • 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 zen, linux-tkg-pds, or Xanmod. This will also prevent the system from becoming unresponsive when under heavy CPU load.
    • linux-tkg-pds (linux-tkg with PDS scheduler) seems to perform better than zen[1], and has lower input lag (this is definitely noticeable in competitive shooters). Some people recommend using linux-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.

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.
  • 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.
    • For AMD GPUs, create the following file: /etc/X11/xorg.conf.d/20-amdgpu.conf with the content:
      Section "Device"
              Identifier "AMD"
              Driver "amdgpu"
              Option "TearFree" "false"
              Option "EnablePageFlip" "false"
      EndSection
      
  • 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!)
  • Environment variables:
    • DXVK_ASYNC=1: Display frames even if they are not completely rendered. This will reduce stuttering a lot, but might trip anti cheat! Your wine version needs to be compatible or patched to use it. Proton-GE is compatible.
  • You might want to have a look at the extensive Arch Wiki page.

Input lag, Desktop Environments, and X11/Wayland

This page needs work, for the following reason(s): Might be outdated, and there is missing data for various desktop environments and window managers. I'm not sure if disabling composition is possible in Cinnamon (the DE of Mint). If it is not possible, this would make Cinnamon one of the worst choices.
  • It appears that KDE Plasma (X11) with no composition (currently) is (one of) the best regarding performance, and input lag. Gnome is also ok.[2]
    • 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.
  • You should only use Wayland if you can enable FreeSync, because otherwise it will force vsync. If you are using KDE and you have FreeSync enabled, the performance and input lag should be close to KDE X11 with composition disabled.[3] 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. KDE Plasma is currently the best DE for Wayland.[4]

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, 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 if your 99th percentile is bad.

AMD/Nvidia specific tweaks

AMD

This page needs work, for the following reason(s): Not sure if other distros contain the vulkan icds in same location as Arch..
  • Use CoreCtrl to add performance profiles for your games, set fan speeds, and overclock/undervolt.
  • 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 (even tho your mileage may vary). If you experience sub-par performance, check which driver you are using.
    • To check which Vulkan implementations are installed on system use this command (system will use amdvlk by default if both are installed): 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.
  • Environment variables:
    • RADV_FORCE_VRS=2x2: Variable rate shading. This will improve performance, but reduce quality of shadows. Alternative values: 2x1 or 1x2 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

Nvidia

This page needs work, for the following reason(s): not complete, and most is just copied from a reddit post.
  • Use DKMS. DKMS is a prerequisite for using custom kernels like Zen, Xanmod or tkg with the Nvidia driver. It also lets you update to newer kernel versions without waiting for an Nvidia driver update. [7]Every distro that has proprietary Nvidia driver support offers a DKMS version.
  • The Arch Wiki is the best place to start. Enable coolbits as the link explains. Good is, setting the coolbits value to 28 on anything currently supported (post-Fermi) to enable full control over the GPU (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.
  • Make sure to use a Proton version of 6.3, Experimental, Proton-6.21-GE-2 or later for Proton-GE and Proton-tkg/wine-tkg-git of 6.17 or greater (or build your own) for DLSS support. For Steam, you need to put PROTON_HIDE_NVIDIA_GPU=0 PROTON_ENABLE_NVAPI=1 %command% in your launch options (side note: there should only ever be one %command%).
  • 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. For non-Steam games, you also need a dxvk.conf file with dxgi.nvapiHack = False in it. You can just create one (mine is ~/Documents/dxvk.conf) and set DXVK_CONFIG_FILE=/path/to/dxvk.conf in your /etc/environment.
  • For Arch-based distributions, use TKG's nvidia-all repo, with _dkms="" set to true in customization.cfg.[8]

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