Xorg is eating up my CPU

I noticed a while back that my CPU usage was suddenly constantly going somewhere between 30–40 % with Xorg using most of it (e.g. now the total usage is 34 %, top shows Xorg using 29 %). The usage used to be something around 5% when working and running multiple tasks, but now it’s up there even on idle right after logging in.

There’s no real lag or anything noticeable, just the stats and the fan running like a maniac. But I’d still like to fix this.

To start off, here’s my basic specs:

OS: Manjaro Linux x86_64 
Host: 82B1 Lenovo Legion 5 15ARH05H 
Kernel: 6.8.0-1-MANJARO 
Uptime: 1 hour, 38 mins 
Packages: 2093 (pacman) 
Shell: bash 5.2.26 
Resolution: 3840x2160, 3840x2160 
WM: i3 
Theme: Catppuccin-Frappe-Standard-Blue-Dark [GTK2/3] 
Icons: Tela-dark [GTK2/3] 
Terminal: kitty 
CPU: AMD Ryzen 7 4800H with Radeon Graphics (16) @ 2.900GHz 
GPU: NVIDIA GeForce RTX 2060 Mobile 

So I have both integrated GPU and a dedicated GPU. I have always used the dedicated one explicitly, as the hybrid mode hasn’t really worked. I’ve read that the hybrid mode with Nvidia can use a lot of CPU though, so I’m thinking if something has changed in that regard or if something has messed up my graphics drivers etc. In BIOS the graphics are set to use the discrete card, so the hybrid model shouldn’t work in any way though.

But of course, the reason could be anything, might be something that’s not related to graphics at all.

Using the laptop’s monitor only or having external monitors (2 x 4K displays) connected has no real effect on the usage. I have also tried disabling picom, as it was an issue a long time ago, but it has no effect here anymore.

What info should I provide here?

1 Like

Have you tried looking at System Monitor? It comes with Manjaro as default. Check the tab Applications in it for example. Maybe something didn’t close completely.

If you prefer the terminal, top, htop etc.
ps -fp “ProcessID” could give a clue too, once you have Xorgs PID. Should be similar/exactly to what htop shows though. But in htop Xorg jumps around for me so harder to read.
Example: ps -fp 1024

Hi @Twkka, and welcome!

Try the following:

top --batch --iterations=1 --sort-override=%CPU | head -n 30

This will list the top processes ordered by CPU use.

1 Like

Please see [HowTo] Request support for helpful information about posting logs.

Thanks to all of you, and sorry for a bit of a delay before getting back to this. So I just rebooted and have only started Firefox with this page open and Kitty for running the commands.

Running

top --batch --iterations=1 --sort-override=%CPU | head -n 30

…gives me:

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   1660 root      20   0   24,2g  68548  46100 S  18,2   0,2   0:43.38 Xorg
   1716 me        20   0  863056  23532  20460 S   9,1   0,1   0:16.77 polybar
   1719 me        20   0  863064  23336  20520 S   9,1   0,1   0:16.86 polybar
 250527 me        20   0   14840   7516   5468 R   9,1   0,0   0:00.01 top
      1 root      20   0   22644  13160  10052 S   0,0   0,0   0:01.72 systemd

The CPU percentage of Xorg is a bit less than what it’s been the past couple of weeks, but still way higher than what it was prior. I also have only the laptop display in use at the moment.

I might do some common tasks for a while and see what happens, usually the percentage gets higher pretty quickly.

18% seems crazy high to me.
With a 6-core 5600X, Xorg sits at 2-3%. With a browser open, watching Twitch.
And why is Virtual so high? 24 gigs? It sits at 1.3 gigs for me. Anomalies for sure.

Polybar, sounds like custom. Did you edit xorg.conf or make files inside /etc/X11/xorg.conf.d/
in the past?

Well polybar is using 9.1% x 2 = 18.2% which seems way too much for a status bar. So I’d start by looking at that.

Hi @Twkka,

To start with, that isn’t the complete output. It should be similar to:

$ top --batch --iterations=1 --sort-override=%CPU | head -n 30
top - 08:50:55 up 10 days, 22:52,  1 user,  load average: 0.58, 0.86, 0.95
Tasks: 318 total,   1 running, 317 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.8 us,  0.0 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  15920.6 total,   5731.4 free,   5853.9 used,   4994.8 buff/cache
MiB Swap:   8000.0 total,   6308.6 free,   1691.4 used.  10066.7 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
1 root      20   0   22.7m   8.5m   5.5m S   0.0   0.1   6:49.66 systemd
2 root      20   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.27 kthreadd
3 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 rcu_gp
4 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 rcu_par+
5 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 slub_fl+
6 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 netns
8 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 kworker+
10 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 mm_perc+
12 root      20   0    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 rcu_tas+
13 root      20   0    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 rcu_tas+
14 root      20   0    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 rcu_tas+
15 root      20   0    0.0m   0.0m   0.0m S   0.0   0.0   0:09.27 ksoftir+
16 root      -2   0    0.0m   0.0m   0.0m I   0.0   0.0   0:35.36 rcu_pre+
17 root      -2   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.00 rcub/0
18 root      rt   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.50 migrati+
19 root     -51   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.00 idle_in+
21 root      20   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.00 cpuhp/0
22 root      20   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.01 cpuhp/1
23 root     -51   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.00 idle_in+
24 root      rt   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.35 migrati+
25 root      20   0    0.0m   0.0m   0.0m S   0.0   0.0   0:02.11 ksoftir+
27 root       0 -20    0.0m   0.0m   0.0m I   0.0   0.0   0:00.00 kworker+
28 root      20   0    0.0m   0.0m   0.0m S   0.0   0.0   0:00.02 cpuhp/2

Then, my Xorg is not hungry at all:

$ top --batch --iterations=1 --sort-override=%CPU | grep -i xorg
[...]
746 root      20   0 6446.7m 110.0m  65.5m S   0.0   0.7 152:17.67 Xorg

So, I strongly suspect Kitty, since it’s GPU based, and Xorg is for graphics. So try exiting that and try another terminal emulator.

1 Like