mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-01-11 14:40:25 +01:00
[BUG]: Maybe a perf issue (high CPU & fan speed) #399
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @KevinNitroG on GitHub (Jun 2, 2024).
Describe the bug
I think the version
0.1.26has a performance issue. I have noticed many times that after using komorebi for a while, my computer's fan goes up and my CPU is about higher +3-5%. It will end up by restarting komorebi (komorebi stopand thenkomorebi start), and the issue comes back after using for a while again.To Reproduce
Steps to reproduce the behavior:
30mins)Expected behaviour
No High CPU and Fan speed
Screenshots and Videos
In the video, we cannot see clearly the amount of CPU that komorebi took. But it affects my computer's CPU and Fan speed that I can feel it.
Operating System
komorebic checkOutputAdditional context
I use AHK. There are few more unrelated config, but I just want to let you know for a more details analysis. My full AHK script is:
My full
komorebi.json:@LGUG2Z commented on GitHub (Jun 2, 2024):
Can you try taking some measurements with a command line tool like https://github.com/ClementTsang/bottom?
We'll need some numbers in order to investigate this further
@KevinNitroG commented on GitHub (Jun 2, 2024):
Thank you for your reply. I will record another video with
bottomlater when the issue comes up.@KevinNitroG commented on GitHub (Jun 2, 2024):
@LGUG2Z Here is the video using
bottom.The fastest way to reproduce this is by switching workspaces continuously (about 100 times? - instead of using komorebi for a while).
@KevinNitroG commented on GitHub (Jun 2, 2024):
I will use the older version
0.1.25and check if the issue appears or not. Then I will let you know later.Edit:
I uninstall using
Then install using
the output
But komorebi still works
@KevinNitroG commented on GitHub (Jun 2, 2024):
Update: I can confirm that the version
0.1.25has no problem with high CPU and fan speed 😶🌫️@LGUG2Z commented on GitHub (Jun 2, 2024):
Looking at your first video where you isolate the komorebi process: the ~20% CPU usage you point to is the total CPU usage across all running processes; komorebi's CPU usage is still 0%.
Similarly for the video with
btmkomorebi's CPU usage seems to peak at0.1%.Generally we target <1% CPU usage for komorebi running in the background and it seems like your measurements are consistent with that.
However I did notice that you seem to be running in 32-bit mode, while you are running other applications such as OBS in 64-bit mode? When you are running previous versions of komorebi are you also making them run in 32-bit mode?
@KevinNitroG commented on GitHub (Jun 2, 2024):
Currently, I'm back to

0.1.25and all of the versions I use, they are all run at 32-bit mode sir.Also I don't know how to run komorebi in 64-bit mode 😥
@LGUG2Z commented on GitHub (Jun 2, 2024):
I wonder if that 32-bit binary is the shim from
scoop? 🤔Since none of the measurements suggest that komorebi is using any more CPU resources than normal, can you check the logs and see and share if there is anything interesting happening there, like threads crashing and restarting?
@KevinNitroG commented on GitHub (Jun 2, 2024):
Recently I tried to back to
0.1.26and try to check the log withkomorebic log. I switch between workspaces and there is no warning, or error log (except high CPU every time checking the log lifetime in the terminal - around + [20,30] % 😐). But I will try again later and let you know if there is any warning or error log.@KevinNitroG commented on GitHub (Jun 2, 2024):
After trying to get some logs in the
0.1.26version, There were some logs that also occurred in0.1.25so I think we cannot find the problem via log 😥.After some try, it couldn't run
komorebic logagain and showed an errorI did restart komorebi, but it couldn't show the log and threw the same error. Same with reinstalling komorebi. (note that
0.1.26)Then I went back to
0.1.25and it could show log normally.Then I reinstalled
0.1.26, and it threw the same error when usingkomorebic log@LGUG2Z commented on GitHub (Jun 2, 2024):
🤦♀️ I forgot there was a regression in the log command that was fixed here on master:
1320b7440eCan you try running
v0.1.27-dev.0from the latest commit on themasterbranch?@KevinNitroG commented on GitHub (Jun 2, 2024):
So I need to build from source right? I have never built a rust project before 😂 Alright I will give it a try tomorrow. And grab if there is any valuable log.
Edit: Is that possible to run directly the .exe from the artifact of github action's workflow, I wonder?
@LGUG2Z commented on GitHub (Jun 2, 2024):
Yeah you can replace the exes on your system with the exes from GitHub actions ^
@KevinNitroG commented on GitHub (Jun 3, 2024):
@LGUG2Z
The issue (High CPU) still exists in fix(cli): make quickstart respect whkd config dir #2003. And there wasn't any valuable log. 😥
@thomasroodnl commented on GitHub (Jun 7, 2024):
Dear @KevinNitroG , @LGUG2Z
I seem to be having a similar issue since v0.1.26. In Task Manager komorebi.exe CPU usage is reported in the 25%-50% range on idle, and by
bottomin the 8-12% range. If I relaunch komorebi it goes back to <1% (on both). I can reproduce it by launching komorebi (which now has all of my windows (~8) in the first workspace) and quickly switching between it and the empty second workspace. Doing this about 20-30 times already gets me in the 4-8% idle CPU usage onbottom.I tried it with less windows (4) and closed some nefarious applications like PyCharm, and I can still reproduce the increased idle CPU.
I think that during my normal workflow this problem gradually increases the idle CPU usage until all my applications start hanging due to how busy the CPU is. Another thing I note is that my
active_window_borders disappear after some time, which may or may not be related to this issue.My setup is as follows:
komorebi.json:
OS:
It is maybe also good to note that I use
yasb, and AutoHotkey v1 for my keybinds.If there is anything that I could test to help track down the problem, please let me know.
@LGUG2Z commented on GitHub (Jun 7, 2024):
This one at least I believe should be fixed on master:
3232d9242a6c90001c00I'm still not able to reproduce this on my end, but I will keep trying - It's possible there are some lock contention issues that only trigger under very specific conditions
@thomasroodnl commented on GitHub (Jun 7, 2024):
Ah that is good to hear, I will try building the current master! In the meantime, I tried reproducing it without
yasband I get the same issue so at least it is not that.@starise commented on GitHub (Jun 8, 2024):
I have the same issue described by @thomasroodnl : I'm working, time passes (hours) and the CPU usage increases until at some point I'm forced to exit komorebi to stop the system being slow. After
komorebic stopall back to normal. In my workflow I also change workspaces several times during the day, moving windows around between workspaces.@LGUG2Z commented on GitHub (Jun 8, 2024):
Is anyone able to reproduce this with borders off?
My working theory is that this comes down to the locks on Mutexes when handling
WM_PAINTon border windows, and this becomes more and more noticable depending on the number of windows on each workspace that the user switches between.@starise commented on GitHub (Jun 8, 2024):
Changed my config to
"border": false. I'll let you know.@LGUG2Z commented on GitHub (Jun 9, 2024):
I've been making some small performance refactors in the border manager's hot path here:
493531e7640940fce05a@LGUG2Z commented on GitHub (Jun 9, 2024):
6b9a0843fdThis should also change the rate at which we trigger the border manager's hot path.
@thomasroodnl commented on GitHub (Jun 10, 2024):
I just tried to replicate it with the borders off and it seems like the issue indeed does not appear. CPU usage stays <1% (in
bottom) both wile switching workspaces and afterwards. I will now build the latest from master and see what the performance is like with the borders enabled.@starise commented on GitHub (Jun 11, 2024):
Same here. Monitored for an entire day with borders disabled and no issues so far.
@LGUG2Z commented on GitHub (Jun 11, 2024):
Any updates to report with the latest changes on the master branch? 🤞
@thomasroodnl commented on GitHub (Jun 11, 2024):
Apologies, I have been running without borders enabled since this was working well so I forgot to check. I recompiled from master just now. With borders enabled I can still elicit the high idle CPU usage with the method as described before.
@LGUG2Z commented on GitHub (Jun 11, 2024):
Some elevated CPU usage is expected for expensive operations like this, especially when spamming workspace changes quickly over a few seconds to force a repro - but does the CPU usage continue to climb and stay high during normal usage and when idling on a single workspace?
@thomasroodnl commented on GitHub (Jun 11, 2024):
Yes that makes sense. In this 'aggressive' reproduction it stays high when idling on a workspace for at least around 5 mins, I have not tested it for a longer period of time as I had to go back to using my pc. To validate further, I will enable the borders during normal usage and keep an eye on the CPU in idle.
@starise commented on GitHub (Jun 11, 2024):
I'm testing this artifact today with borders on, and after a couple hours the system started to be sluggish with komorebi cpu usage from ~6-8% (in idle) to ~13-14% (peaks).
Tried a couple of
komorebic border disable; komorebic border enablefrom PS but actually CPU usage increased a bit in idle. Only way to free resource is to start fresh withkomorebic stop; komorebic start.@LGUG2Z commented on GitHub (Jun 12, 2024):
I think I'm gonna have to try this out on a potato laptop 🤔
Can you share your hardware stats? For ref, I am testing this on a Ryzen 5900x
Similarly, it would be useful if anyone still experiencing high CPU usage could use Visual Studio to attach to the process and profile the CPU usage for a couple of minutes (hit "break all" after letting it run) to identify the hot code paths as it runs on your machines:
https://learn.microsoft.com/en-us/visualstudio/debugger/attach-to-running-processes-with-the-visual-studio-debugger?view=vs-2022
@starise commented on GitHub (Jun 12, 2024):
Sure, same CPU here 😅 - OS : Windows 11 (10.0.26100.712) - CPU : Ryzen 5900X - RAM : 64 GB - VGA: Radeon RX 6800 XT - Display (single) @ 2160p, 120Hz, 200% scaling. I'm using komorebi with 4 workspaces and these are my common apps: explorer, terminal, firefox, vscode, xnview mp, figma, davinci resolve.
@thomasroodnl commented on GitHub (Jun 12, 2024):
Today I used komorebi with the borders enabled without any violent workspace shifting. After around 4 hours the CPU usage was noticeably high in idle (4-8%), even after not doing any window switches for several minutes. I performed the profiling like you requested and got the following summary:
During this recording I did not interact with the machine. Please let me know if you need a different view of this trace or need me to send you the trace file (I'd need to figure out how first).
Oh and also, the 'potato laptop' hit home :). I am running a 12th Gen Intel(R) Core(TM) i7-1255U, and 16 GB of RAM. No dedicated graphics card. Current test was with single display @ 1440p, 100Hz, 100% scaling. 5 workspaces.
@CtByte commented on GitHub (Jun 12, 2024):
I've been using Komorebi for 7 hours now with borders and transparency enabled. I have many windows open (6 terminals, 2 Visual Studio 2022, Teams, Chrome, Firefox, etc)
I did a little test where I grabbed a window an observed the CPU usage:
https://github.com/LGUG2Z/komorebi/assets/165908630/a790c1ef-b933-4277-bd2a-7ea450492325
I only observed considerable CPU usage while I was holding the window. It went back to 0%
I am using the
67a3c3546fversion which I built myself using Visual Studio 2022. I copied the exe files to thec:\Program Files\komorebi\bin\folder. I don't really think that it has anything to do with the files you are testing with, but I thought I mention it.I use stackbar a lot and having transparency+borders does not seem to be an issue for me.
Could this have more to do with workspaces? or perhaps the fact that you don't have dedicated GPU to render the borders and other graphical intense workloads so Windows reserves a bit of the CPU for when it needs to use the integrated GPU (it does that with RAM)?
Edit: After reading a bit more above, I can see that others with a dedicated GPU have similar issues. This one is difficult to crack.
@LGUG2Z commented on GitHub (Jun 12, 2024):
Since this issue is getting quite long, here is a quick summary of what the investigation so far has shown:
komorebi.execontinues to consume CPU cycles at a growing rate over the lifetime of the processA few things that come to mind for the next steps:
border_managermoduleborder_manager, the underlying issue is probably somewhere in the Win32 system calls we are makingupdateandcallbackfunctionsupdatetriggersInvalidateRectwhich triggers theWM_PAINTmessage being sent to each border window67a3c3546f/komorebi/src/border_manager/border.rs (L123-L137)67a3c3546f/komorebi/src/border_manager/border.rs (L152-L211)Although this is not documented in the
WM_PAINTdocs, there is an old StackOverflow comment which states:Since we are calling
if let Ok(rect) = WindowsApi::window_rect(window) {}as the very first step in theWM_PAINThandler, it's possible that this call could fail, triggering theWM_PAINTmessage loops for a small subset of borders. We don't have any logging here to validate whether or not this is the case, but it should be possible to add both error logging and to push theBeginPaintandEndPaintcalls outside of therectcontext.All of the Win32 system calls here are GDI-related, so if you are a game dev using
komorebiand you're reading this, please double check all of my assumptions. 😅Edit: The changes to the
WM_PAINThandler have been made onmaster, and I've also added another change which only triggers theWM_PAINTmessage if either the focus state or the rect position has changed.@LGUG2Z commented on GitHub (Jun 14, 2024):
Has anyone been able to run with the latest changes? 🤞
@starise commented on GitHub (Jun 14, 2024):
I'm testing
c022438a37right now and the situation looks much better. Changing workspace frequently caused some cpu spikes but nothing dramatic. On idle cpu usage seems under control. I also noticed less memory utilization overall. I'll monitor the situation under a more extensive period of time. I'll keep you updated. 👌@Q0 commented on GitHub (Jun 15, 2024):
I’m sitting on
c022438and in general everything is very stable. I have never had a window border break (previously it often broke when actively working with windows). The review is positive.@LGUG2Z commented on GitHub (Jun 15, 2024):
@thomasroodnl @KevinNitroG if either if you can also confirm the improvements on your end we should be able to close this and begin the next release cycle 🤞
@thomasroodnl commented on GitHub (Jun 15, 2024):
Great to hear the changes seem to be having the desired effect :). I'm sorry, I haven't had the opportunity yet to build the latest version and run it, but I will give it a try coming Monday and report my findings.
@KevinNitroG commented on GitHub (Jun 16, 2024):
@LGUG2Z Hi again. I think the commit
c022438a37is fine now. I haven't had enough long time to test but within an hour, my CPU's fan doesn't complain about komorebi anymore.Also, this is not related to this issue. If I use
komorebic closewhile on the desktop, it will close the windows explorer which makes the icon disappear. Is it ... a feature? 😶🌫️Thank you for having looked into the bug. Love your project!
EDIT: BUT WAIT... 😅
Please let us test a bit more. I just want to ensure whether the issue is gone completely or not.
Edit: Not yet fine...
@KevinNitroG commented on GitHub (Jun 17, 2024):
@LGUG2Z. I'm testing
c022438a37for more than an hour and it seems that the issue hasn't gone completely yet I guess. My fan still goes up, but the CPU doesn't show that much, and I can only show you via the CPU temp.https://github.com/LGUG2Z/komorebi/assets/86353526/a3e19acf-9c9a-4ed7-9b6d-61ac09638549
After restarting komorebi, my fan goes down.
I will test it again and feedback to you later. But I think I will leave this issue soon because of personal busy. 😅
@KevinNitroG commented on GitHub (Jun 17, 2024):
https://github.com/LGUG2Z/komorebi/assets/86353526/2a6c1906-d297-4a42-a9c8-d415de459617
Here is another video shows that my CPU temp is high, and decrease after restarting komorebi
@thomasroodnl commented on GitHub (Jun 17, 2024):
From a quick look the CPU performance seems largely improved. I can still repro the high idle CPU usage with the fast workspace switching, but I will just run it normally throughout the day and see how the idle looks for me under a more realistic workload. In any case, thanks for the improvements!
@thomasroodnl commented on GitHub (Jun 17, 2024):
Just ran it for 4 hours on normal use. Idle komorebi CPU usage hovers around 1-4%. For me this is fine honestly, I haven't noticed any freezing or slowdown due to the extra CPU usage. But it seems there is still something going on in the background. I wanted to note that in general, the stability of the boundaries has improved significantly for me over the past updates.
@LGUG2Z commented on GitHub (Jun 18, 2024):
I'm going to close out this issue now; the core issue that we were able to measure through komorebi's CPU usage growing over time has been resolved, and I don't think we can take any investigation into hardware temperatures further right now since our main metrics (CPU usage) have completely normalized.
@starise commented on GitHub (Jun 18, 2024):
Sadly I have to report that komorebi cpu usage gone wild again for me right now (Screenshot). 😢 I noticed that every time I switch the workspace, back and forth, it triggers new "Create Thread" events and never exit the threads.
@LGUG2Z commented on GitHub (Jun 18, 2024):
Do you have any errors in the logs which show threads crashing and bring restarted when you are changing workspaces? 🤔
@starise commented on GitHub (Jun 18, 2024):
You mean
komorebic log? I uploaded a small video to show what I mean, I was watching "SimpleProgramDebugger" output and it looks like new threads are created every time I change a workspace, but I'm doing nothing except switching between the same 2 workspaces. The threads remain active and are closed onkomorebic stop.Uploaded a video here (Sry: GitHub has 10MB limit): https://streamable.com/p2x31u
@LGUG2Z commented on GitHub (Jun 18, 2024):
These calls to CreateThread aren't being made from
komorebidirectly to the best of my knowledge, but it may be something in a library that we are calling. Another thing to make sure of is whether we see the same debugger output even when there is no elevated CPU usage 🤔@starise commented on GitHub (Jun 18, 2024):
If you take a closer look at my video, the cpu usage of
komorebi.exeis very low (launched just in that moment). What has high cpu usage iskomorebic.exe(after komorebic log command).@LGUG2Z commented on GitHub (Jun 19, 2024):
@starise fixed the issue with threads not being terminated for border and stackbar windows ^
@LGUG2Z commented on GitHub (Jun 20, 2024):
@KevinNitroG I'm guessing this might also have been the cause of your CPU temp issues 🤔
@KevinNitroG commented on GitHub (Jun 20, 2024):
Do you think about reopening this issue, for anyone else having the same issue to find? Because I've just installed the latest version
0.1.27and the CPU usage is not really positive. I'm staying at0.1.25for now...@LGUG2Z commented on GitHub (Jun 20, 2024):
I can't really make anything out of statements like these about CPU without hard numbers.
If you have CPU usage readings like this to share, or even better, comparative readings across different versions in similar conditions, it gives people something to investigate.
@KevinNitroG commented on GitHub (Jun 20, 2024):
Sorry that I couldn't help you much. That's only I can give you about my case. I don't know about threads and how to watch the threads or something. Try
komorebic logand nothing seems to be related to the issue. I did try my best to show you the issue has not gone yet.