-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Maybe a perf issue (high CPU & fan speed) #862
Comments
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 |
Thank you for your reply. I will record another video with |
@LGUG2Z Here is the video using The fastest way to reproduce this is by switching workspaces continuously (about 100 times? - instead of using komorebi for a while). |
I will use the older version Edit: I uninstall using scoop uninstall komorebi -p
scoop cleanup -a Then install using scoop install komorebi@0.1.25 the output
But komorebi still works |
Update: I can confirm that the version |
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 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? |
I wonder if that 32-bit binary is the shim from 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? |
Recently I tried to back to |
After trying to get some logs in the
After some try, it couldn't run
I did restart komorebi, but it couldn't show the log and threw the same error. Same with reinstalling komorebi. (note that Then I went back to Then I reinstalled |
🤦♀️ I forgot there was a regression in the log command that was fixed here on master: 1320b74 Can you try running |
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? |
Yeah you can replace the exes on your system with the exes from GitHub actions ^ |
The issue (High CPU) still exists in fix(cli): make quickstart respect whkd config dir #2003. And there wasn't any valuable log. 😥 |
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 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 My setup is as follows: komorebi.json: {
"$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.26/schema.json",
"app_specific_configuration_path": "C:/Users/trood/Repos/komorebi-config/applications.yaml",
"window_hiding_behaviour": "Cloak",
"cross_monitor_move_behaviour": "Insert",
"float_rules": [], // REDACTED
"unmanaged_window_operation_behaviour": "Op",
"default_workspace_padding": 1,
"default_container_padding": 1,
"border_padding": 0,
"border_offset": 0,
"active_window_border": true,
"border_width": 3,
"global_work_area_offset": {"bottom": -40, "left": 0, "right": 0, "top": 0},
"active_window_border_colours": {
"single": "#7582f8",
"stack": "#7582f8",
"monocle": "#9a45fa"
},
"monitors": [
{
"workspaces": [
{ "name": "0_I", "layout": "VerticalStack" },
{ "name": "0_II", "layout": "VerticalStack" },
{ "name": "0_III", "layout": "VerticalStack" },
{ "name": "0_IV", "layout": "VerticalStack" },
{ "name": "0_V", "layout": "VerticalStack" }
]
},
{
"workspaces": [
{ "name": "1_I", "layout": "VerticalStack" },
{ "name": "1_II", "layout": "VerticalStack" },
{ "name": "1_III", "layout": "VerticalStack" },
{ "name": "1_IV", "layout": "VerticalStack" },
{ "name": "1_V", "layout": "VerticalStack" }
]
},
{
"workspaces": [
{ "name": "2_I", "layout": "Rows" },
{ "name": "2_II", "layout": "Rows" },
{ "name": "2_III", "layout": "Rows" },
{ "name": "2_IV", "layout": "Rows" },
{ "name": "2_V", "layout": "Rows" }
]
}
]
} OS:
It is maybe also good to note that I use If there is anything that I could test to help track down the problem, please let me know. |
This one at least I believe should be fixed on master: I'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 |
Ah that is good to hear, I will try building the current master! In the meantime, I tried reproducing it without |
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 |
Is anyone able to reproduce this with borders off? My working theory is that this comes down to the locks on Mutexes when handling |
Changed my config to |
This should also change the rate at which we trigger the border manager's hot path. |
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 |
Same here. Monitored for an entire day with borders disabled and no issues so far. |
Any updates to report with the latest changes on the master branch? 🤞 |
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. |
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? |
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. |
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 |
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. |
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. |
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: Recording.2024-06-12.145005.Moving.window.-.Dedicated.mp4I only observed considerable CPU usage while I was holding the window. It went back to 0% I am using the 67a3c35 version which I built myself using Visual Studio 2022. I copied the exe files to the 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. |
Since this issue is getting quite long, here is a quick summary of what the investigation so far has shown:
A few things that come to mind for the next steps:
komorebi/komorebi/src/border_manager/border.rs Lines 123 to 137 in 67a3c35
komorebi/komorebi/src/border_manager/border.rs Lines 152 to 211 in 67a3c35
Although this is not documented in the
Since we are calling All of the Win32 system calls here are GDI-related, so if you are a game dev using Edit: The changes to the |
This commit pushes up the calls to BeginPaint and EndPaint in the border callback function to ensure that the client area of the border rect is always validated after calls to InvalidateRect from the update fn. The callback now also logs errors whenever it is not possible to get the border rect to operate on for any reason. There was a call at the end of this logic to ValidateRect which has been removed as the validation is already handled by the call to BeginPaint. re #862
This commit ensures that we only invalidate a border rect to send a WM_PAINT message either when the position of the focus state of the border has changed. re #862
This commit increases various channel bounds from 5 to 20 since it was discovered that this reduction had no impact on #862, and some crashes/freezes have been noted due to the channel bounds of 5 being too low.
Has anyone been able to run with the latest changes? 🤞 |
I'm testing c022438 right 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. 👌 |
I’m sitting on c022438 and 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. |
@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 🤞 |
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. |
@LGUG2Z Hi again. I think the commit c022438 is 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 Thank you for having looked into the bug. Love your project! EDIT: BUT WAIT... 😅 Edit: Not yet fine... |
@LGUG2Z. I'm testing c022438 for 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. 2024-06-17_10-36-19.mp4After 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. 😅 |
2024-06-17_11-21-31.mp4Here is another video shows that my CPU temp is high, and decrease after restarting komorebi |
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! |
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. |
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. |
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. |
Do you have any errors in the logs which show threads crashing and bring restarted when you are changing workspaces? 🤔 |
You mean Uploaded a video here (Sry: GitHub has 10MB limit): https://streamable.com/p2x31u |
These calls to CreateThread aren't being made from |
If you take a closer look at my video, the cpu usage of |
This commit ensures that message handling threads for windows that are created by komorebi are exited properly when the windows are destroyed. For some reason, passing the HWND returned by CreateWindowExW to GetMessageW continues returning TRUE even after the window has been destroyed. If HWND::NULL (via the Default trait) is passed to GetMessageW, which retrieves messages for any window belonging to the current thread (our threads here only own a single window), GetMessageW returns FALSE as expected after the window is destroyed. re #862
@starise fixed the issue with threads not being terminated for border and stackbar windows ^ |
@KevinNitroG I'm guessing this might also have been the cause of your CPU temp issues 🤔 |
Do you think about reopening this issue, for anyone else having the same issue to find? Because I've just installed the latest version |
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. |
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 |
Describe the bug
I think the version
0.1.26
has 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 stop
and thenkomorebi start
), and the issue comes back after using for a while again.To Reproduce
Steps to reproduce the behavior:
30
mins)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 check
OutputAdditional 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
:The text was updated successfully, but these errors were encountered: