Why Ubuntu 22.04 is so fast (and how to make it faster)

Wow. You da man. Okay what about applying the workaround and moving from xorg to wayland. What do you recommend

I wish I could recommend Wayland for NVIDIA, and it might be OK for you, but there are too many bugs in NVIDIA Wayland sessions.

Instead it’s probably best to stick with Xorg and:

  1. Edit /etc/environment and add:
    __GL_SYNC_TO_VBLANK=0
    
    At a guess, that will remove the need for the __GL_SYNC_DISPLAY_DEVICE workaround too.
  2. Reboot.
5 Likes

Hi @vanvugt looks like this is working beautifully. I will be testing for the whole week so if you need to assign me anything else to test and provide feedback in the proper bug report links, I will be happy to assist you in any way. Thank you friend, this helps me while working on the computer.

1 Like

Hello @vanvugt , after reading your amazing explanation, I’m left wondering, is triple buffering Wayland only? The benefits of triple buffering disappear in my case when I’m using Xorg.

My hardware (asus vivobook 14 m413da, amd 5 3500U, radeon vega 8) has very strange performance on most desktop environments, showing bad frame rates specially on window manager specific animations (like gnome’s overview, kde’s and cinnamon’s different fancy animations).

This hardware renders Windows 10/11 animations perfectly and lots of intensive tasks (in both win and linux) without issue, but window manager animations in linux? Nope.

Triple buffering fixes the issue on Wayland, making Gnome go completely smooth even on a high load on battery power (truly amazing!). BUT, for some reason, the bad frame rates on the overview return on Xorg.
Aside the main question, “is triple buffering Wayland only?”, do you have any idea where things might have gone wrong to display animations so badly in so recent hardware (2019)? No amount of smart searching and asking on diverse forums lead to any solution.

1 Like

@raxelgrande,

Triple buffering applies to both Xorg and Wayland. In fact it was working on Xorg about a year earlier than Wayland, and then the remaining year was spent fixing the Wayland issues.

Prior to triple buffering (e.g. Ubuntu 20.04) I would expect Xorg to perform better than Wayland because being a separate process grants it some of the asynchronous benefits of triple buffering. After triple buffering (Ubuntu 22.04 and later) I expect Wayland should perform better as the asynchronicity is about the same but there is no round trip between two different display server processes on every frame. So that’s the first area where Xorg is slower.

Here’s a list of reasons why Xorg might perform worse:

  • Extra round trip between the gnome-shell and Xorg processes on every frame.
  • Xorg drivers mostly can’t handle multi-monitors well and may stutter (LP#1820832).
  • Multi-GPUs: This logic is very different between Xorg and Wayland. Mostly I expect Wayland to be slower (tracking in mutter#2315) but it’s theoretically possible that the Xorg driver you have is less efficient at this than mutter’s Wayland implementation. This is an issue that many laptop owners will hit unknowingly when they plug in a monitor and that port is wired to a discrete GPU.
  • The Xorg driver fails to provide 3 or 4 framebuffers. That would cause serious stutter (or crashes) but I have not seen it happen on desktop drivers yet.
4 Likes

@raxelgrande, I am testing with AMD now and can confirm Wayland sessions are more responsive than Xorg as expected. But nothing buggy and no “bad frame rates”.

To get your Xorg performance issue investigated further, please log in to “Ubuntu on Xorg” and then run:

ubuntu-bug gnome-shell
4 Likes

These performance tips are awesome. Ubuntu is now smoother than ever on my Chromebook with Intel UHD 600 Graphics!

1 Like

@raxelgrande, are you using Ubuntu 22.10? I was able to reproduce the problem you describe after switching back to Intel graphics: https://launchpad.net/bugs/1989582 and have traced it to a regression in mutter 43.

3 Likes

When I run sudo nano /etc/environment if I want to include the two commands you mentioned above to help test on my own Nvidia MX150 GPU/Intel hybrid laptop setup running Xorg, should /etc/environment look like the following below or does it all need to go within the first line in the quotes? Appreciate any clarity thank you. Running Ubuntu 22.04.1 LTS, btw.

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
CLUTTER_PAINT=disable-dynamic-max-render-time
__GL_SYNC_TO_VBLANK=0

in 22.04 and onwards you should really not edit /etc/environment … there were some efforts done to integrate with systemd’s /etc/environment.d/ to avoid this …
perhaps @vanvugt can change the instructions accordingly …

the right way would be:

echo  "CLUTTER_PAINT=disable-dynamic-max-render-time" | sudo tee -a /etc/environment.d/90clutter.conf
echo "__GL_SYNC_TO_VBLANK=0" | sudo tee -a /etc/environment.d/90vblank.conf

(and then indeed do a reboot to make the change take effect)

8 Likes

The issue i was having on Xorg got fixed!

A really timely coincidence, before doing the ubuntu-bug report i did a performance test with video playback and other apps in workspaces using battery power and it worked perfectly (less smooth than wayland, but smooth)

I can pinpoint the issue appearing in Gnome 3.38 (3.36 had no bad frame rate issues) and it lasted to a Gnome 42.2+ point release (last time i tested Ubuntu showcasing the error, was around early July). Currently, on Ubuntu 22.04.1 it works perfectly both on Xorg and Wayland.
It also happened on multiple distros, with near unnoticeable frame drops in Tumbleweed, Arch and an awful performance on Fedora.
i don’t know if the fix is ubuntu specific or a gnome one, i need to test it, but whatever changed between July and September fixed it.

The issue i had is different from the bugs you linked. The best description is “under a medium-heavy load using xorg and battery power (happens plugged in with less notoriety), the gnome-shell animation would reduce the frame rate to about 15fps, even in scenarios where the system should have more than enough resources to render the animations well.”

I also noticed that the bug is made more notorious depending on what battery utility program you use, setting power-profiles-daemon to power save mode drastically reduced frame rates on the overview.
auto-cpufreq was the one that made the bug worse, with even worse frame rates on low/idle use.
tlp gave the best performance on battery and plugged, showing little to no drops in frame rates.

I suspect power-profiles-daemon can have a negative effect on triple buffering, could be worth testing performance.

Yes, on the AMD Ryzen 5500U with Radeon IGPU, Wayland was significantly faster and smoother than Windows 10.

Wow, this cleared up both of my annoyances with 22.04:

  • Occasional mouse stutter (fixed by MUTTER_DEBUG_ENABLE_ATOMIC_KMS=0)
  • Video “jerkiness” (fixed by MOZ_ENABLE_WAYLAND=1)

:heart:

2 Likes

Wow, this cleared up both of my annoyances with 22.04:

I’m hopeful those workarounds won’t be needed in future…

  • Occasional mouse stutter (fixed by MUTTER_DEBUG_ENABLE_ATOMIC_KMS=0)

Upstream has a plan to make mouse input and cursor movement more tightly coupled so hopefully in future atomic KMS will perform at least as well as non-atomic KMS.

  • Video “jerkiness” (fixed by MOZ_ENABLE_WAYLAND=1)

I don’t know Mozilla’s plans but they have defaulted to Wayland in the past. That was only reverted while they fix bugs so one has to assume they will default to Wayland again in future.

5 Likes

3 posts were split to a new topic: Why Ubuntu 22.04 is so slow

February 2023 Update

Upstreaming of triple buffering to mutter (44 or 45) is progressing steadily. The three merge requests are as follows:

  • !2087 has been merged upstream into mutter 44.0
  • !1968 has been redesigned to suit upstream’s requests, but another redesign will be required to resolve the remaining issues open there.
  • !1441 recently reached zero unresolved issues but still depends on !1968. Recently a bug fix was added that has reduced CPU usage during cursor movement and will also reduce rendering latency by one frame in some cases. The same fix is also on its way to lunar for Ubuntu 23.04, and then older releases will follow.

I’m on a break from triple buffering at the moment to work on other Ubuntu/Canonical priorities but will be returning to it probably within a month or two. Regardless of when upstreaming is completed, Ubuntu will continue to ship with stable triple buffering patches which are maintained here: gnome-42, gnome-43.

9 Likes

@vanvugt thanks so much for the tips, in reference to @ogra point, what would be your advice?
Thank you!
Sam

you save my ubuntu experience ! Tnx !

1 Like

This is cool if you have the hardware. On a Chromebook with 4gb of RAM, and an m3 with integrated graphics. It hates Ubuntu. Wish I had enough for a Lenovo laptop. My desktop runs Ubuntu like butter though.

The laptop prefers arch with a custom selection of packages. This is a really great right up. Thanks for the pointers.

@harveykid, I don’t consider that Chromebook old hardware so I’d like to see more details to find out why it “hates Ubuntu”. If you can install Ubuntu on it again then please run this command:

ubuntu-bug gnome-shell

so we can analyse it.

2 Likes