koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.12k stars 640 forks source link

High power consumption? #1759

Open domhel opened 1 year ago

domhel commented 1 year ago

Hi,

ever since installing yabai a few months ago, I have the feeling that my battery drains quite faster. I can only assume that it comes from this package, which might be unfair, because it can very well come from macOS updates or other packages.

My setup:

I have checked the monitor and there is a service consuming a lot of CPU which I assume is used by this package:

Screenshot 2023-05-26 at 17 45 53

Are my assumptions wrong? Is it because I am on Ventura, which is not yet supported officially?

Thank you for insights

koekeishiya commented 1 year ago

You are probably better off looking at the energy consumption, rather than pure CPU time: https://support.apple.com/en-gb/guide/activity-monitor/actmntr43697/mac

aashish2057 commented 8 months ago

I have the same problem with yabai, when my mac is asleep it will drain battery 50% overnight. If I look in activity monitor I can see that the WindowServer is preventing sleep. I am on Sonoma, with a m2 pro and yabai version 6.0.2. The interesting thing is I suspect this has something to do with disabling SIP, as I also run yabai on my work laptop which is also on Sonoma, m2 pro and yabai version 6.0.2 and has no problems with battery draining overnight. @koekeishiya any ideas on what could be causing this? Would prefer not to have to disable sip.

For note on my activity monitor for my work mac where I do not have sip disabled, activity monitor shows that window manager is not preventing sleep. Hence my thinking that sip is causing this battery draining problem.

Screenshot 2024-01-04 at 8 35 19 AM

aashish2057 commented 7 months ago

has anyone has a chance to look into this or has new releases addressed this?

koekeishiya commented 6 months ago

Not sure why WindowServer would prevent sleep, and I don't see why yabai would somehow cause that to happen. I suppose the best suggestion I can give you is to re-enable SIP on the machine that has this issue and see if that resolves it.

I don't use my mac enough to be able to actually look at and compare power consumption over time, and how various degrees of yabai usage impact said usage. I suspect that having focus-follows-mouse enabled could have an impact here, as it means that yabai needs to get notified every time the cursor moves.

For the most part, yabai itself is idle, as can also be seen by its cpu usage. Memory usage is also very low. yabai is event driven and will only actually do something when the system (macOS) notifies it of some event, or when the user themselves run a command through the messaging interface.

If power consumption is increased because of activity in the WindowServer as a result of event subscriptions, there isn't really much that can be done here from my perspective. yabai is already set up and structured in a way that attempts to minimize redundant work. The event subscriptions that are set up are required in order to provide this kind of experience/control on macOS.

I am open for potential changes, but it would require some kind of energy profiling to be done, to identify yabai usage patterns that lead to quantifiable changes in battery lifetime. Only then can I actually say whether the situation can be improved or not. This is not something that is feasible for me to do myself, with the way I currently use my mbp.

koekeishiya commented 6 months ago

Just an update that I often leave my machine unplugged in sleep mode over night (with yabai running) and battery is always more or less the same as I left it on. I am also running with SIP disabled, so I don't think your problem is necessarily caused by yabai.

MarcWeber commented 1 month ago

Well using block mode and adding windows a lot of windows get resized causing additional calculations draining the battery. Eg if you have 10 browser open and they get resized whenever a window appears or goes away .. much more work. https://github.com/koekeishiya/yabai/issues/2360 See column layout (or yabai stacks?) which might preserve window sizes ? So while its not directly yabai its layout might cause programs to use more energy.