Ubuntu not optimized for gaming

Ubuntu Support Template

Ubuntu Version:
Example: 26.04 LTS x86_64

Desktop Environment: Gnome Wayland

Problem Description:
I can run video games on windows at 165fps just fine, but when I try on Ubuntu, I get around 110-120fps and then lag spikes every second after a few minutes.

Relevant System Information:

Kernel: 7.0.0-15-generic

Shell: bash 5.3.9

CPU: Intel i7-14700HX (28) @ 5.300GH
GPU: Intel Raptor Lake-S UHD Graphic (iGPU)
GPU: NVIDIA GeForce RTX 5060 Max-Q (dGPU)

Memory: 4653MiB / 15192MiB

I also installed Steam as a .deb package instead of flatpak.
What I’ve Tried:
”PROTON_ENABLE_WAYLAND=1” in steam launch options

Using Proton Hotfix instead of Proton Experimental

I made sure I had the latest nvidia driver on Ubuntu: sudo apt install nvidia-driver-595-open

Added a graphics driver ppa: sudo add-apt-repository ppa:graphics-drivers/ppa

Made sure my dGPU was prioritized: sudo prime-select nvidia

Added kisak-mesa ppa: sudo add-apt-repository ppa:kisak/kisak-mesa

And of course, I’ve been rebooting after each of these and using sudo apt update && sudo apt upgrade alot.

Any help is appreciated, I just want to be able to have a smooth Ubuntu experience ^^

You can give sudo apt install gamescope a try, and run your games like gamescope -w 1920 -h 1080 -f -- <game>. It’s a “microcompositor” which should remove GNOME from the graphics side of things.

This is from the Arch Wiki but should give you an idea of what it does:
https://wiki.archlinux.org/title/Gamescope

Disclaimer: I don’t do gaming anymore, so I haven’t tested any of this, but Gamescope came up on one of my searches for a somewhat related topic and it seems to be “the right thing to do” when one wants to dedicate all the hardware to game FPS; unless one goes several steps further and uses the Cage kiosk compositor to launch games as sole Wayland apps in their own user session.

1 Like

Do I have to put in the directory for the game, or just the name of it?

I’ve also noticed steam is a little choppy when I’m scrolling through it, also something that doesn’t happen on Windows.

Essentially you run it just the same as you would without gamescope, so if the program executable can be found in your system’s PATH you can omit the full path, e.g. to run doom would now be gamescope -w 1920 -h 1080 -f -- doom

The game I’m testing is Overwatch (which I’ve been able to run smoothly on Windows and CachyOS), but I seem to get an error mentioning “No such file or directory” when I try gamescope -w 1920 -h 1080 -f –- overwatch (exactly as you wrote) and gamescope -w 2560 -h 1600 -f -- overwatch(my laptop’s resolution).

Here’s a pastebin of all that happens: https://pastebin.com/zpmeJt4a

Maybe take a look

1 Like

You need to be careful when copying stuff from this Discourse, because sometimes it makes a double dash (--) into a long dash, like in your quoted command string: –- overwatch. It is also likely that the overwatch executable is not in $PATH. Plus, Linux is case-sensitive, so if it’s OverWatch.exe or something like it on Windows, you do need to preserve the proper capitalization, and the .exe.

I tried the command again, making sure to use double dashes, to the same result.

I searched for mentions of overwatch from the home folder and got this:

When I copied the path of Overwatch.exe and ran gamescope -W 2560 -H 1600 -r 165 -f -- /home/krs/.steam/debian-installation/steamapps/common/Overwatch, I get this error:

[gamescopereaper] [Error] process: Failed to start process “/home/krs/.steam/debian-installation/steamapps/common/Overwatch”: Permission denied

I also tried gamescope -W 2560 -H 1600 -r 165 -f -- /home/krs/.steam/debian-installation/steamapps/common/Overwatch.exe, but I get the “no such file or directory error” again.

I looked through https://wiki.archlinux.org/title/Gamescope for more information. I saw that I could try adding gamescope -W 1920 -H 1080 -r 60 -- %command% to the game’s launch options (in section 2.3), but that cause lag spikes and overall bad performance from the menu, even if i do gamescope -W 2560 -H 1600 -r 165 -- %command%.

What’s in that Overwatch.desktop file? It should contain some Exec= line, which you can just amend.

How did you do that? We need details to be able to help. Also, adding the -r parameter is for limiting a vsync’d game’s refresh rate to a fixed value.

Apologies, I’ll show a screenshot of how I entered it if that’s what you mean:

I right clicked the game, and clicked “Properties…” to end up in this menu.

I see this when I click on Overwatch.desktop:

And by amend, do you mean just deleting that whole Exec=steam steam://rungameid/2357570 line?

And what did that line say before you edited it?

Oh no, never mind then. That’s just some kind of remote control for Steam. Actually, if you’re using Steam, you should be able to integrate Gamescope there, probably as a global launcher option, because that’s what it was made for to begin with, IIUC.

In the launch options text line I only had PROTON_ENABLE_WAYLAND=1.

Would you be able to tell me how to integrate gamescope into steam?

If there wasn’t any actual command before (PROTON_ENABLE_WAYLAND=1 is just an environment variable assignment), then it’s probably not the right place to just add a command line, that may have resulted in an additional instance of your game in the background, which could explain your lag spikes.

Would you be able to tell me how to integrate gamescope into steam?

No, as I said, not a gamer anymore so I don’t know the specifics. You may be better off asking that sort of question on a Steam forum. Essentially there must be some generic command line template, which you need to edit so every game gets launched inside Gamescope, hence the %command% (%var% is DOS batch speak for $var) variable in all the examples. I’d start by looking for global launcher options.

Thanks for the pointers, I’ll look into gamescope a bit more.

I’ve spent this past week trying different distros and getting them to play nice with my games and being stable. I’ve tried this one, Mint Cinnamon, PopOS and CachyOS. Cachy was able to run my games smoothly, but I ran into several weird issues with mic and audio that came and went seemingly at random. It’s a little frustrating that these distros aren’t “working out the box” for me like others say they are, but I really want to make this work. I feel like Windows is straying down a path that doesn’t prioritize their users, and being able to have a linux distro for me to come to incase they reach a point of no return eases my worries.

I’m sure you’ll get there eventually. I think Ubuntu is a solid base for gaming, actually, but given its general purpose nature you may need to tweak some things to get the most FPS. Maybe just start with manually putting your machine in “performance” mode before launching a game.

You should also not expect the exact same performance on Linux, even with the same Nvidia driver version.
https://www.phoronix.com/review/nvidia2022-windows11-linux

That’s the most recent comparison of some games between Windows 11 and Linux. Overwatch is not part of the test suite, though, but it should give you an idea of what reasonable expectations look like. Often times more consistent frame latency seems to come at the price of some peak FPS readings. But since you reported having latency spikes you seem to be paying the price without return on investment so to speak.

you can change the swappiness value to make Linux use more of your RAM before any type of swap file

https://www.geeksforgeeks.org/linux-unix/how-to-change-the-swappiness-of-your-linux-system/

you can also increase systems VM Max Map to its max of 1048576

https://stackoverflow.com/questions/42889241/how-to-increase-vm-max-map-count

this may help to improve game play on Ubuntu.

It represented by a value between 0 and 100.

That’s obviously an outdated HowTo, because the range has been 0 to 200 for quite some time now. I also doubt that swapping is the issue here. But it can also be checked, if that’s the case:

swapon --show

FWIW, there is this really well-written article about Linux swap:

(referenced in systemd-oomd.service(8))

That’s a bit of a stretch.

2 Likes

As an afterthought to that, not having swap, i.e. the above command reveals there to be no swap space available at all (or vm.swappiness = 0), can also negatively impact gaming performance, because without swap, all the kernel can do to reclaim memory is evicting filesystem cache (page cache) data. Such data can dominate in games, I reckon, because of huge levels being loaded from files on disk, so a stutter when turning around in some shooter might just be due to the kernel having to stall the game until said level data has been re-fetched from a slow(-ish) storage device – SSD’s are still orders of magnitude slower than DRAM and have a higher access latency on top of that.

I really think this would be premature optimization, but I’d be remiss to not mention this article from the same author:

With modern CPU’s zswap is essentially providing free additional RAM. One can then even think about going above and beyond vm.swappiness = 100 – I am currently at 133 and have 1.6 GiB of rather stale memory in zswap; at a compression ratio of 2.6, I’ve effectively gained an additional 1 GiB of RAM.

i have a 2GB swap file and 3GB of zram set with zram given a higher priority. i have 64GB DDR4 3200 of ram.

swappiness is set to 25

vm.max_map_count set to 1048576

i have radeon onboard graphics not a dedicated GPU and everything is running as smooth as silk ..

Until you hit an LRU inversion, when the zRAM swap space is full and spills over to the lower priority swap file. There really is no point in having both, real swap space and fake zRAM swap; more details in the 2nd of Down’s articles.

You may want to consider adding more real swap space, though, because of zswap’s current design, which is in the process of being modernized.

It’s also not really an achievement when you start with 64 GiB RAM; try limiting the available RAM to something like 16 or even 8 GiB.

1 Like