hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.95k stars 912 forks source link

Hyprland is consuming 70 % of CPU all the time. [Perf report attached] #7356

Open TwilightTechie opened 3 months ago

TwilightTechie commented 3 months ago

Regression?

No

System Info and Version

My hyprland config: https://pastebin.com/6Th64wuT

Description

CPU is constantly consuming more than 70% of CPU sometimes even 80%.

Here is my spec:

OS: Arch Linux x86_64
Host: 82BH Yoga 7 14ITL5
Kernel: 6.10.4-arch2-1 
Shell: zsh 5.9 
Resolution: 1920x1080 
DE: Hyprland
 CPU: 11th Gen Intel i7-1165G7 (8) @ 4.700GHz 
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics]
Memory: 3444MiB / 15792MiB

I am using this config: https://github.com/prasanthrangan/hyprdots

CPU detail spec: ❯ inxi -C

CPU:
  Info: quad core model: 11th Gen Intel Core i7-1165G7 bits: 64 type: MT MCP
    cache: L2: 5 MiB
  Speed (MHz): avg: 1362 min/max: 400/4700 cores: 1: 3270 2: 400 3: 399
    4: 2309 5: 2752 6: 471 7: 400 8: 902

Detail GPU Spec:

❯ inxi -G
Graphics:
  Device-1: Intel TigerLake-LP GT2 [Iris Xe Graphics] driver: i915 v: kernel
  Device-2: Generic Integrated Camera driver: uvcvideo type: USB
  Display: wayland server: X.org v: 1.21.1.13 with: Xwayland v: 24.1.2
    compositor: Hyprland v: 0.42.0 driver: X: loaded: modesetting dri: iris
    gpu: i915 resolution: 1920x1080~60Hz
  API: EGL Message: EGL data requires eglinfo. Check --recommends.

I did some analysis based on htop, perf tool and generated a flame graph.

perf command used:

❯ perf record -F 99 -p 15872 -g -- sleep 30
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.477 MB perf.data (2550 samples) ]

Here is the gecko report and flamegraph for analysis. perf

gecko perf report

How to reproduce

Nothing as such, it is on simple workload

Crash reports, logs, images, videos

hyprland.log hyprland.log

vaxerski commented 3 months ago

does this happen on 0.41.2?

you have logging disabled, the logs are empty. see debug:disable_logs

can you get a trace log? https://wiki.hyprland.org/Crashes-and-Bugs/#obtaining-a-trace-log

TwilightTechie commented 3 months ago

Hi, I am pretty new here so asking:

So you want me to add HYPRLAND_TRACE=1 AQ_TRACE=1 in ~/.config/hypr/hyprland.conf then wait for 30 sec - 1 min (as my issue is not something to be reproduce and it is happening now also) then share the generated logs.Btw in which location this logs will get generated?

vaxerski commented 3 months ago

So you want me to add HYPRLAND_TRACE=1 AQ_TRACE=1

No, launch hyprland with HYPRLAND_TRACE=1 AQ_TRACE=1 Hyprland in a tty

Btw in which location this logs will get generated?

https://wiki.hyprland.org/Crashes-and-Bugs/#getting-the-log

Make sure debug:disable_logs is false in your config

TwilightTechie commented 3 months ago

Is this you were looking for, I don't see much log so not sure, can you please check.

❯ cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr/ | head -n 2 | tail -n 1)/hyprland.log
[LOG] Instance Signature: 9a09eac79b85c846e3a865a9078a3f8ff65a9259_1723750879_1891595009
[LOG] Runtime directory: /run/user/1000/hypr/9a09eac79b85c846e3a865a9078a3f8ff65a9259_1723750879_1891595009
[LOG] Hyprland PID: 913
[LOG] ===== SYSTEM INFO: =====
[LOG] System name: Linux
[LOG] Node name: archlinux
[LOG] Release: 6.10.4-arch2-1
[LOG] Version: #1 SMP PREEMPT_DYNAMIC Sun, 11 Aug 2024 16:19:06 +0000

[LOG] GPU information:
0000:00:02.0 VGA compatible controller [0300]: Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics] [8086:9a49] (rev 01) (prog-if 00 [VGA controller])

[LOG] os-release:
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo

[LOG] ========================

[INFO] If you are crashing, or encounter any bugs, please consult https://wiki.hyprland.org/Crashes-and-Bugs/

[LOG] 
Current splash: We're all living in America, America, America.

[LOG] Old rlimit: soft -> 1024, hard -> 524288
[LOG] New rlimit: soft -> 524288, hard -> 524288
[LOG] Creating the EventLoopManager!
[LOG] Creating the HookSystem!
[LOG] Creating the KeybindManager!
[LOG] Creating the AnimationManager!
[LOG] Created a bezier curve, baked 255 points, mem usage: 4.08kB, time to bake: 16.55µs. Estimated average calc time: 0.04µs.
[LOG] Creating the ConfigManager!
[LOG] Created a bezier curve, baked 255 points, mem usage: 4.08kB, time to bake: 7.63µs. Estimated average calc time: 0.02µs.
[LOG] Using config: /home/hardway/.config/hypr/hyprland.conf
[INFO] !!!!HEY YOU, YES YOU!!!!: further logs to stdout / logfile are disabled by default. BEFORE SENDING THIS LOG, ENABLE THEM. Use debug:disable_logs = false to do so: https://wiki.hyprland.org/Configuring/Variables/#debug
vaxerski commented 3 months ago

you didnt enable logging

TwilightTechie commented 3 months ago

Hi, logs were huge so uploaded in google drive as github only allows till 25 MB. https://drive.google.com/drive/folders/1KMOkLyQnGUeHML-XRJmPKGjVY11P0LCn?usp=sharing

TwilightTechie commented 3 months ago

you didnt enable logging

Now it is done, check the google drive link.

vaxerski commented 3 months ago

hm, can you try on aquamarine-git and hyprland-git?

If that doesn't fix it, try to get some DRM logs. See the sway wiki for instructions.

https://github.com/swaywm/wlroots/wiki/DRM-Debugging

Judging from your logs, keeping Hyprland open for 5s should be enough.

TwilightTechie commented 3 months ago

Here is the DRM log dmesg.log

TwilightTechie commented 3 months ago

hm, can you try on aquamarine-git and hyprland-git?

I didn't get you here.

romanstingler commented 3 months ago

There are 2 packages in the AUR aquamarine-git and hyprland-git these have the latest available code. Can you install these packages and try again.

vaxerski commented 3 months ago

oh I see the bug already, huh, didn't know that could happen.

vaxerski commented 3 months ago

I've pushed a patch to aquamarine. Pull latest aquamarine-git and try again :)

TwilightTechie commented 3 months ago

Awesome, would love you to know how you found the bug and what it was about..... Is it related to DRM?

vaxerski commented 3 months ago

well we dont know if that was the only problem or whether it's truly fixed, only you can test that, but the drm logs the error quite clearly:

image

The damage clip box is invalid

TwilightTechie commented 3 months ago

I've pushed a patch to aquamarine. Pull latest aquamarine-git and try again :)

Again, I am a noob.... I need steps on how to do so because I have installed it from package manager not through git. So I don't know the build process.

vaxerski commented 3 months ago

you're on arch, and the package is in the AUR. Use your favorite AUR helper (yay/paru) to install the package aquamarine-git

TwilightTechie commented 3 months ago

I dont think it is taking your patch.

` yay -S aquamarine-git AUR Explicit (1): aquamarine-git-0.1.0_r147.g7a84686-1 AUR Dependency (1): hyprutils-git-0.1.1.r3.g0693f939-1 AUR Make Dependency (1): hyprwayland-scanner-git-0.1.0.r1.geb11420c-1 Sync Make Dependency (1): cmake-3.30.2-1 :: PKGBUILD up to date, skipping download: aquamarine-git :: PKGBUILD up to date, skipping download: hyprwayland-scanner-git :: PKGBUILD up to date, skipping download: hyprutils-git 3 aquamarine-git (Build Files Exist) 2 hyprwayland-scanner-git (Build Files Exist) 1 hyprutils-git (Build Files Exist) ==> Packages to cleanBuild? ==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4) ==> A :: Deleting (1/3): /home/hardway/.cache/yay/aquamarine-git HEAD is now at 3300d7a aquamarine-git: Update SRCINFO :: Deleting (2/3): /home/hardway/.cache/yay/hyprwayland-scanner-git HEAD is now at 8b43aca changed desc :: Deleting (3/3): /home/hardway/.cache/yay/hyprutils-git HEAD is now at ac76c29 slightly updated provides 3 aquamarine-git (Build Files Exist) 2 hyprwayland-scanner-git (Build Files Exist) 1 hyprutils-git (Build Files Exist) ==> Diffs to show? ==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4) ==> A

:: Proceed with install? [Y/n] `

romanstingler commented 3 months ago

@TwilightTechie just press Y

TwilightTechie commented 3 months ago
looking for conflicting packages...
:: aquamarine-git-0.3.1_r178.ge947af7-1 and aquamarine-0.3.1-1 are in conflict. Remove aquamarine? [y/N] Y
error: failed to prepare transaction (could not satisfy dependencies)
:: removing aquamarine breaks dependency 'libaquamarine.so=2-64' required by hyprland
 -> error installing: [/home/hardway/.cache/yay/aquamarine-git/aquamarine-git-0.3.1_r178.ge947af7-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-debug-0.3.1_r178.ge947af7-1-any.pkg.tar.zst] - exit status 1

Should I press N here :)

romanstingler commented 3 months ago

yay -S hyprland-git aquamarine-git

replaces both

TwilightTechie commented 3 months ago

Thanks, easy way

TwilightTechie commented 3 months ago

Again it broke.... First at here:

:: hyprcursor-git-0.1.9.r11.g912d5602-1 and hyprcursor-0.1.9-1 are in conflict. Remove hyprcursor? [y/N] Y
:: aquamarine-git-0.3.1_r178.ge947af7-1 and aquamarine-0.3.1-1 are in conflict. Remove aquamarine? [y/N] Y
error: failed to prepare transaction (could not satisfy dependencies)
:: removing aquamarine breaks dependency 'libaquamarine.so=2-64' required by hyprland
 -> Failed to install layer, rolling up to next layer.error:error installing: [/home/hardway/.cache/yay/hyprcursor-git/hyprcursor-git-0.1.9.r11.g912d5602-1-any.pkg.tar.zst /home/hardway/.cache/yay/hyprcursor-git/hyprcursor-git-debug-0.1.9.r11.g912d5602-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-0.3.1_r178.ge947af7-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-debug-0.3.1_r178.ge947af7-1-any.pkg.tar.zst] - exit status 1
==> Making package: hyprcursor-git 0.1.9.r11.g912d5602-1 (Fri 16 Aug 2024 02:33:15 AM IST)

Then here


==> Making package: hyprland-git 0.42.0.r1.83a334f9-1 (Fri 16 Aug 2024 02:33:22 AM IST)
==> Checking runtime dependencies...
==> Missing dependencies:
  -> hyprcursor-git
==> Checking buildtime dependencies...
==> ERROR: Could not resolve all dependencies.
 -> error making: hyprland-git-exit status 8
loading packages...
resolving dependencies...
looking for conflicting packages...
:: hyprcursor-git-0.1.9.r11.g912d5602-1 and hyprcursor-0.1.9-1 are in conflict. Remove hyprcursor? [y/N] Y
:: aquamarine-git-0.3.1_r178.ge947af7-1 and aquamarine-0.3.1-1 are in conflict. Remove aquamarine? [y/N] Y
error: failed to prepare transaction (could not satisfy dependencies)
:: removing aquamarine breaks dependency 'libaquamarine.so=2-64' required by hyprland
 -> error installing: [/home/hardway/.cache/yay/hyprcursor-git/hyprcursor-git-0.1.9.r11.g912d5602-1-any.pkg.tar.zst /home/hardway/.cache/yay/hyprcursor-git/hyprcursor-git-debug-0.1.9.r11.g912d5602-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-0.3.1_r178.ge947af7-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-debug-0.3.1_r178.ge947af7-1-any.pkg.tar.zst] - exit status 1
error installing: [/home/hardway/.cache/yay/hyprcursor-git/hyprcursor-git-0.1.9.r11.g912d5602-1-any.pkg.tar.zst /home/hardway/.cache/yay/hyprcursor-git/hyprcursor-git-debug-0.1.9.r11.g912d5602-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-0.3.1_r178.ge947af7-1-any.pkg.tar.zst /home/hardway/.cache/yay/aquamarine-git/aquamarine-git-debug-0.3.1_r178.ge947af7-1-any.pkg.tar.zst] - exit status 1
vaxerski commented 3 months ago

remove hyprland and aquamarine first

yay -R hyprland aquamarine

then install git

Avimitin commented 3 months ago

Using hyprland-git and aquamarine-git seems like doesn't fix this issue. Also I notice that using the -git version Hyprland eat more vram than before.

image

$ hyprctl version
Hyprland, built from branch main at commit 12d9901472c6f9128fa8b16c25b3a879d1859e60  (protocols: refactor protocol logging to a macro (7324)).
Date: Fri Aug 16 00:16:18 2024
Tag: v0.42.0-26-g12d99014, commits: 5095

flags: (if any)

$ yay -Qm hyprland aquamarine
hyprland-git 0.42.0.r26.12d99014-1
aquamarine-git 0.3.1_r178.ge947af7-1
vaxerski commented 3 months ago

maybe your issue is different. Can you post a trace log?

Avimitin commented 3 months ago

Yes after multiple tests, I think this is an different issue, I will open a new issue instead.

TwilightTechie commented 3 months ago

Currently using hyprland-git and aquamarine-git and CPU usage is around 9%. Is that normal @vaxerski ?

I checked the DRM logs and it seems to have no error now... dmesg2.log

image

urugang commented 3 months ago

same here. logs show

[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
[ERR] [EGL] Command eglCreateSyncKHR errored out with EGL_BAD_ATTRIBUTE (0x12292): _eglCreateSync
[ERR] eglCreateSyncKHR failed
urugang commented 3 months ago

revert to 0.41.2-3, then peace fell upon the earth again.

sudo -E pacman -U https://archive.archlinux.org/packages/h/hyprland/hyprland-0.41.2-3-x86_64.pkg.tar.zst
vaxerski commented 3 months ago

great, instead of helping fix the bug, stay on legacy forever. Great attitude.

@TwilightTechie sounds normal if you have something constantly changing on-screen, border animations tend to do that. Is it 9% also on an empty workspace?

TwilightTechie commented 3 months ago

I would say a normal workload like having multiple terminals, firefox, connected to external monitors.

vaxerski commented 3 months ago

what about the second part of my question?

shilkazx commented 3 months ago

Hi @vaxerski, I'm wandering on the bug list and occasionally take notice of cpu usage(p.s. I do not meet this severe bug). My cpu is 12th Gen Intel(R) Core(TM) i5-12500H and It seems the 0.42 version slightly increase the cpu usage than 0.41.x(I'm not very sure, but it should be). I compared the blank workspace and normal working load. If both of two monitor is on blank workspace, my cpu usage is about 1%(use waybar's cpu module); when one monitor open a blank terminal(zsh in terminator), it increased 1% to 2%; when keep the blank terminal on and let other monitor open firefox(on this git page and typing the comment), the cpu usage up to 3%(I am a layman of graphic, but it is counter-intuitive that a blank terminal and a firefox web page use same cpu resource for rendering ).

vaxerski commented 3 months ago

if you can reliably differentiate between the two, please bisect :)

bayi commented 3 months ago

Hi

I have a intel i7 4770 and using it to run my session also i have a nvidia RTX 3060 which i use to offload rendering ( in games for example ) .

I had the same bug as above ( high cpu usage and everything was flickering on movement, my terminal was unusuable had to wait 3-4 seconds to read anything ). I reverted back to 0.41 for now, also the -git packages didnt helped ( although the CPU load went a little bit down from avg 90% to avg 60% )

Avimitin commented 3 months ago

I have a question: is it normal to have 20%~25% CPU usage for moving cursor around?

urugang commented 3 months ago

it is about 30% cpu only single process with version 0.41.2-3. I only watched 15% cpu previously.

with 0.42, it is about 50%cpu eight processes (my cpu has 8 hardware threads), and cause that desktop almost can not response, even dmenu with short keycut.

vaxerski commented 3 months ago

I have a question: is it normal to have 20%~25% CPU usage for moving cursor around?

with software cursors it sounds plausible. With hardware cursors, it's suspiciously high

Avimitin commented 3 months ago

with software cursors it sounds plausible. With hardware cursors, it's suspiciously high

I've tried the below options:

cursor {
    no_hardware_cursors = false
    allow_dumb_copy = true
}

But the CPU usage is still keep around 20%-25%. Do I mistaken on something?

vaxerski commented 3 months ago

should work. Dunno then

urugang commented 3 months ago

from 016da234 ( Core: Move to aquamarine ), it starts to show big delay.

urugang commented 3 months ago

image

it seems latest branch have not used any gpu. for cpu only, I think 50% cpu load is rational.

Robitx commented 2 months ago

@vaxerski same/similar issue here - laggy, high cpu usage, running on latest git for both hyprland and aquamarine, trace log here: hyprland.log

urugang commented 2 months ago

in hyprland 0.43.0-1, it's only 10%cpu, 1%gpu, 173MB host memory, 305MB gpu memory. for me, it's normal and same performance like before.

wxqwinner commented 2 months ago

The dual monitors CPU is still high. image image

vaxerski commented 2 months ago

@Robitx disable explicit sync

wxqwinner commented 2 months ago

@Robitx disable explicit sync

Thanks.

gulafaran commented 1 month ago

while profiling on nvidia moving the cursor it spends like 70% inside the driver doing shed_yield, i remember back in the day there was some workarounds or trickery one could try. setting __GL_YIELD=USLEEP , and yeah cpu usage goes way down. but as this ancient https://forums.developer.nvidia.com/t/gl-yield-and-performance-issues/27736 post mentions it might kill fps, over here i dropped from 70% cpu usage just moving cursor down to 10% or so instead.