Ubuntu 24.04 Boosts Gaming Performance

Here is the video and some of points I was mentioning about the overall improvements between past Ubuntu versions and Ubuntu 24.04 (Including 23.10, 23.04 and 22.10 which were the ones used for testing games like Cyberpunk).

So basically it is the total amount of tests and the performance benefits between October 2022 and April 2024.

Video - https://www.youtube.com/watch?v=OCpvexMQLfU (If you would like to help, the only thing you can do is subscribe to the channel so it does not look like an abandoned warehouse from cyberpunk or leave comments with other ideas to test).

And here are the pictures from Cyberpunk in Ubuntu 22.10 / 23.04 versus Ubuntu 24.04

The 1st one here is Ubuntu 22.10 / 23.04 at 4K with Raytracing (Using X11).

oldOne

The 2nd one here is the same area, with Raytracing, 4K, X11 but on ubuntu 24.04

As you can see from the images (Both videos are on my channel): you can see the FPS jump from an average below 40 fps, to above 100 FPS (Almost 3X better performance with everything enabled).

Same thing happened when comparing The Witcher 3 and other games.

7 Likes

Hi there,

As you can see from Fine-Tuning the Ubuntu 24.04 Kernel for low latency, throughput, and power efficiency, there were some improvements to the kernel this cycle which you might be seeing form a gaming perspective. I, too, have seen much improved performance in this arena from both a gaming and audio engineering perspective.

As such, if you add preempt=full to your kernel command parameters as shown in the topic I just linked, you might see even more improvements. :slight_smile:

6 Likes

…and things are about to get even more exciting for gaming / audio once we’ll have an official Ubuntu kernel with sched_ext (possibly in 24.10). This will allow you to dynamically switch CPU schedulers at runtime and choose the one that best suits your specific workload. Some schedulers, such as scx_rusty, scx_lavd, and scx_rustland, seem to show promising results for gaming.

6 Likes

Thank you @eeickmeyer @arighi I went ahead and did the preempt=full on the kernel and got this:

newOne1

newOne2

I mean, first, congratulations on the voodoo you do (or did) in Ubuntu 24.04. May I ask, based on the images here:

  1. Does the preempt affect the power management for the GPU Card (It is a 4090). Why did I get more FPS with less power usage?

  2. Why the bigger boost in FPS. I was expecting probably 5% max, not almost 100% more in some scenarios.

The only change I did like an hour ago was the testing of the 6.9 Kernel and the preempt kernel idea.

photo_2024-06-12_13-41-04

Here is my hardware, but what I am trying to understand is how did the preempt or other optimizations have an impact like that so I can try to explain them during a video about Ubuntu 24.04.

The sched_ext I did see the improvements there too. Amazing!!

For the preempt, I did try researching here:

https://stackoverflow.com/questions/817059/what-is-preemption-what-is-a-preemtible-kernel-what-is-it-good-for#:~:text=A%20preemptive%20operating%20system%20can,this%20switching%20is%20essentially%20trasnparent.

https://www.kernel.org/doc/html/v6.6/admin-guide/kernel-parameters.html

And I do get most of it. I would guess (please correct me) is that the kernel would guess beforehand some optimizations and ways of using the scheduler for specific scenarios.

5 Likes

Thanks for sharing this, @luisalvarado! I’ve been following your channel for a while and it’s a great resource for gamers in our community.

3 Likes

Wow. Thank you very much friend. Really appreciate you saying that.

Is that mangohud you’re using?

Correct. I need to create the setup video about it (Forgot about it)

1 Like

In short, by default the preemption model used by the Ubuntu kernel is “voluntary”. This means that once you’re in kernel space the current running tasks can’t be interrupted, unless they hit specific functions (such as might_sleep(), cond_resched() or exit_to_user_mode_loop()), where if the task flag TIF_NEED_RESCHED is set the task can be interrupted and replaced by another one running at higher priority.

With preempt=full the current running tasks can always be interrupted at anytime (unless they’re holding a lock or they are in a critical section where preemption has been explicitly disabled).

Having more interruptions mean extra overhead, that can reduce the overall system throughput (like number crunching tasks can get worse performance), but it also helps to reduce the average wait time of latency-sensitive tasks that need to get the CPU “as quick as possible” to perform certain quick actions (this type of workload is typical for gaming).

So, in general, if your typical workload is number crunching apps, preempt=voluntary is better, if you run a latency-sensitive workload preempt=full is better.

About power consumption, one interesting result that I have found after switching from CONFIG_HZ=250 to CONFIG_HZ=1000 in 24.04 was a noticeable reduction in power consumption across different workloads. CONFIG_HZ determines how many times per second the system tick runs (used as a periodic source of interrupt for scheduling purposes and perform periodic kernel jobs). It seems counter-intuitive that increasing the frequency can reduce power consumption, but apparently it seems that having more interruptions help to give more chances to the CPUs to go idle faster. Considering that entering idle state (and remaining in idle state as much as possible) is the most effective way nowdays to reduce CPU power consumption, this explains the reduced power with the increased CONFIG_HZ.

So, I’m wondering if we are experiencing a similar situation here with the GPU power consumption by switching to preempt=full.

2 Likes

I suppose it should be noted here that the benchmarker is using the DEB version of Steam, and as far as i know the deb version cannot be installed right from the App Center?

New users install what is available there without knowing the still apparent limitations of Steam’s Snap version (many games don’t launch yet they do on deb version of Steam).

I think, sorting these things out should be quite urgent by now. Or at least making the deb version easily installable from the App Center because Snap Steam is just not on par yet.

Edit: When asked whether he used Wayland or X11, he replied “always X11 (Wayland is not yet ready for something like this. They are coming along but whatever the masses say, by doing simple tests yourself you can see Wayland still needs some additional work)”.

So again, as far as i know, also Wayland is now default on new Ubuntu and additionally problematic in means of at least gaming :thinking:

Hey @heidi_wenger since Steam cannot be included in the Ubuntu archives it cannot be surfaced in the App Center. The Steam snap compatibility issues are being actively worked on and a new update with broader permissions will be available soon that should resolve most outstanding deltas.

Wayland is not the default for NVIDIA graphics cards in Ubuntu, that still defaults to X11. :slight_smile:

I plugged this thread in my latest roadmap update to promote the discussion :slight_smile:

2 Likes

Amazing! Appreciated a million times :heart_eyes:

2 Likes

Hi, good points there, but I should add these videos:

Testing DEB, Flatpak & Snap in Gaming (Part 1) - https://www.youtube.com/watch?v=2FBnTa33jSQ

Testing DEB, Flatpak & Snap in Gaming (Part 2) - https://www.youtube.com/watch?v=fLPagwYhxeU

And add the note I mentioned last time I talked about this. I was hesitant from using Snap when it came out (Yes, loading took too long, apps did not know what Linux was nor where to save files, things broke, etc…).

This was a couple of years ago. It was VERY unlikely to be used for gaming. Fast forward to January of 2024 and I suddenly find myself with a CSGO issue with the DEB package (The official one from Steam).

I did the videos above with the premise of showing that the issues of:

  • Stuttering on high end hardware
  • Loading in Window mode instead of fullscreen (Even if you set it as fullscreen)
  • Constant FPS drops
  • Low FPS values for the hardware I have
  • Input Lag (sometimes even input stuttering)
  • Other user / hardware issue

Were happening on all cases (DEB, Flatpak, Snap). The point of the videos started because I wanted to record the issue I was having mainly with stuttering to Valve in their git repo.

During the first video, after proving that both DEB and Flatpak had the huge stuttering, I was confident that Snap would also have it. And based on “popular” word of mouth about Snap being crap, I had the fallacy that it would be worse on Snap.

2 videos later, and what did I learn from my last time I tested Snap, versus the current snap (For me):

  • Snap had 2x better FPS
  • Snap did NOT have stuttering
  • Snap did not have the fullscreen issue
  • Snap had better input latency. I had to test this several times because my brain was not processing this, since I got used to the input lag on DEB.
  • Snap loaded CSGO much faster (by a lot).

And the only thing I was actually trying to test was the stuttering and I ended up with this surprise. I learn first, to talk directly to the snap software engineers, not the community at large, I like being objective about stuff like this, so then I can recommend it properly. So, performance wise, at least on CSGO, is simply amazing and I will be testing many more games on Snap, Flatpak and DEB because, similar to others, I REALLY want to see what the performance difference is. Snap went from a horrible experience from me, to a game changer (Literally a GAME changer).

Now, is it perfect? Not yet. I say not yet because if we analyze the timeline of development, the improvements of snap, not only on gaming, but other apps as well, the ubuntu software engineers are doing a BEAUTIFUL job at it. Just amazing. They might be shy in constantly showing the improvements to the community but that is part of being an engineer. We got no time to be advertising every little improvement. That is where people like me jump in. To have a voice about the progress.

From the huge improvements of 24.04 for gaming I have seen so far, to the community planned ideas found for 24.10 at Ubuntu Desktop’s 24.10 Dev Cycle - The Roadmap - #4

Now, of course snap for gaming is not there yet. For example if you see me using mangohud is because I am using DEB instead of snap or flatpak. I do understand that keeping up to mangohud changes (I compile it myself) is tough, same for other tools for gaming. Probably gamemode from Feral and other things people use (Probably modding or shader tools, etc…). But can we really say Snap is not progressing. No we can’t. By testing CSGO I had to shut up and learn the hard way the ubuntu developers are taking this to another level. So I am confident that most likely an idea will come up, for example, where snap would create some kind of rules of apps it can keep track from the system and allow access to in order to play nice with them. Meaning, if I compile the latest mangohud on Ubuntu, the snap steam version will detect it and I might even be able to set which apps it can “see” from the system.

Anyway, this is (is what I feel) becoming like when 10.10 was about to come out and everyone worked together to create the Ubuntu 10.10 we wanted at the time.

Can you just imagine an Ubuntu where DEB packages get installed easily for the end user, optimizations based on community and more. 24.10 is going to become some kind of beast, the go to distro for gaming.

Lastly, note that the Wayland gaming experience is a hit and miss. For me is bad on Nvidia. This is not an Ubuntu specific, not Gnome / KDE specific, not Kerner specific, not Mesa specific, nor Video driver specific. But the sum of all of those. The Linux kernel needed some changes for it, Nvidia needed some changes for it, AMD too. Wayland / Mutter needed some changes for it. Gnome / KDE too. Etc… Basically, the whole group of teams everywhere are working EXTRA hard to make sure, most likely, by the end of 2024, the Linux ecosystem can count on HDR (Fully, not partially), Explicity / Implicit Sync, and maybe hopefully other cool things like:

  • Frame Generation
  • DLSS / DLAA (3.x or whatever latest Nvidia has, or FSR or any of AMD / Intel)
  • Reflex (I think this is already there)
  • HDR
2 Likes

So this definitely would indicate that the Snap package of Steam is the way to go! After the rough edges have been sorted out, there appears something powerful in Snap tech. Maybe it’s the inclusion of all (and things that are plus?) dependencies inside same thing.

Very interesting! Your doings are proving important and encouraging for the Snap future :+1:

1 Like

The Steam snap depends on a content snap called ‘gaming-graphics-core22’ that fast tracks newer mesa versions and other userspace optimisations so games running via steam get the benefits of those improvements without affecting the stability of the host system. This should contribute to performance improvements in a number of use-cases (however I can’t claim to know that this is the reason in this particular case). I wrote about this in a blog a while back :slight_smile: What? The Steam snap is evolving! | Snapcraft

6 Likes

We do have preliminary support for MangoHUD included in the Snap that you can read more about on our Wiki here: FAQ ¡ canonical/steam-snap Wiki ¡ GitHub. Right now the games that will work with it are limited, but that might improve this cycle due to some unrelated improvements we have planned to the Snap.

We also have started GameMode support, but we are still waiting on upstream work to be approved before continuing forward.

3 Likes

Great start there. I am assuming (please correct me) the goal I am guessing is that if the MangoHUD gets updated on the system (For example I compile it myself, or gets downloaded), Snap Steam would “detect” the version there and use it. That would literally kill the need for the DEB case in many cases for benchmark / recording.

So many of the liquorix/zen improvements for desktop are in 24.04 kernels, it seems.

For the time being we are working on getting MangoHUD working and updated within the Steam Snap itself, but adding “your own” version of MangoHUD, GameMode, etc. might be something we investigate in the future.

1 Like

Things are getting juicy.