-
Notifications
You must be signed in to change notification settings - Fork 52
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
Centaur Tabs causing high CPU on macOS #88
Comments
I face this problem in same environment. |
That's pretty odd, in fact I've been doing some performance optimizations in order to avoid constant unnecessary recalculations. I would need something more specific like a trace given that I don't have access to any macOS devices. |
@tnira that's really really odd because the commits after 0383af0 just do two things:
I would like to see if this persists on a non macOS environment, so if any of you have access to another system please check if the problem persists there. |
I did a clean install of ubuntu18 and installed only centaur-tabs with default settings for spacemacs. |
That's pretty interesting. Spacemacs tends to misbehave from time to time. As far as I know this doesn't happen in Doom. It probably has to do with the timer I added and something inside Spacemacs having conflicts with it. Some information about what function is consuming the time or something like a trace would be really helpful. Maybe using elp to profile certain key functions like |
That Spacemacs profiler report worries me a little bit. I don't quite understand why |
Just want to confirm that I have this problem too, and after disabling |
With the help of the all mighty Doom Emacs owner, I think we have a potential solution to the performance and flickering problems, although I will be able to try it until Sunday because I'm on vacation and I didn't bring my laptop. |
Caused by over-zealous doom-switch-window-hook. For my own sanity (and if you're curious), I'll break it down here: 1. Doom has a `doom-switch-window-hook` hook. It triggers when window focus is changed. 2. We use `buffer-list-update-hook` to trigger `doom-switch-window-hook`. (That may sound weird, but this hook is reliably executed when window focus is changed -- there are safeguards to prevent this from triggering too often) 3. `buffer-list-update-hook` triggers whenever a buffer is created, but `doom-switch-window-hook` only triggers if the created buffer is in a new window. 4. The use of `with-temp-buffer` in `centaur-tabs-line-format` counts as "buffer creation" in a "new window". 5. `+vc-gutter-update-h` is in `doom-switch-window-hook`. This refreshes git-gutter, which initiates a redraw of Emacs. 6. When Emacs redraws, it recalculates its mode and header lines. which triggers `doom-switch-window-hook` once, which triggers `+vc-gutter-update-h`, which redraws the screen, then Emacs recalculates the header line, running `centaur-tabs-line-format`... Infinite loop ensues Hopefully fixes: - #2436 - ema2159/centaur-tabs#18 - ema2159/centaur-tabs#88
Caused by over-zealous doom-switch-window-hook. For my own sanity (and if you're curious), I'll break it down here: 1. Doom has a `doom-switch-window-hook` hook. It triggers when window focus is changed. 2. We use `buffer-list-update-hook` to trigger `doom-switch-window-hook`. (That may sound weird, but this hook is reliably executed when window focus is changed -- there are safeguards to prevent this from triggering too often) 3. `buffer-list-update-hook` triggers whenever a buffer is created, but `doom-switch-window-hook` only triggers if the created buffer is in a new window. 4. The use of `with-temp-buffer` in `centaur-tabs-line-format` counts as "buffer creation" in a "new window". 5. `+vc-gutter-update-h` is in `doom-switch-window-hook`. This refreshes git-gutter, which initiates a redraw of Emacs. 6. When Emacs redraws, it recalculates its mode and header lines. which triggers `doom-switch-window-hook` once, which triggers `+vc-gutter-update-h`, which redraws the screen, then Emacs recalculates the header line, running `centaur-tabs-line-format`... Infinite loop ensues Hopefully fixes: - doomemacs#2436 - ema2159/centaur-tabs#18 - ema2159/centaur-tabs#88
Done! It should be fixed now. |
Hmm. It's still not fixed for me unfortunately. I made sure that my |
@sorawee could you show me a screenshot from the profiler? |
Note that if I revert the changes in 3658efc, the issue goes away. |
@sorawee are you sure that you updated the package correctly? |
I tried to Another thing I'm curious is, for c3254ef, you add |
@sorawee. I'm not quite sure, that's what Henrik (Doom maintainer) advised me to do. He explains some details here: daveduthie/doom-emacs@73f29cc. |
I can confirm this issue on Ubuntu 18.04, using Emacs 27 on release tip (not spacemacs). Profiler shows a total of 50% CPU usage from Centaur tabs during light editing (e.g. commenting-out lines). I'm using the icons integration with centaur tabs, but otherwise it's stock. As soon as I disable centaur tabs, Emacs is smooth as butter. |
Just to answer my own question. In elisp, this form of |
@sorawee now I understand. The problem was that the |
Caused by over-zealous doom-switch-window-hook. For my own sanity (and if you're curious), I'll break it down here: 1. Doom has a `doom-switch-window-hook` hook. It triggers when window focus is changed. 2. We use `buffer-list-update-hook` to trigger `doom-switch-window-hook`. (That may sound weird, but this hook is reliably executed when window focus is changed -- there are safeguards to prevent this from triggering too often) 3. `buffer-list-update-hook` triggers whenever a buffer is created, but `doom-switch-window-hook` only triggers if the created buffer is in a new window. 4. The use of `with-temp-buffer` in `centaur-tabs-line-format` counts as "buffer creation" in a "new window". 5. `+vc-gutter-update-h` is in `doom-switch-window-hook`. This refreshes git-gutter, which initiates a redraw of Emacs. 6. When Emacs redraws, it recalculates its mode and header lines. which triggers `doom-switch-window-hook` once, which triggers `+vc-gutter-update-h`, which redraws the screen, then Emacs recalculates the header line, running `centaur-tabs-line-format`... Infinite loop ensues Hopefully fixes: - doomemacs#2436 - ema2159/centaur-tabs#18 - ema2159/centaur-tabs#88
@sorawee @mexisme @tnira @xml-js-dev how about now? |
It's fixed! Thank you :) |
Finally! Thanks!!!! |
A quick note: while it's finally not taking 90% CPU usage, it's still taking about 30%. While this is totally manageable for me, it might suggest that there's a lurking bug somewhere... |
Using Spacemacs on macOS, I get very high CPU usage when Centaur Tabs is enabled:
htop
) when running with a GUIredisplay_internal
function, which seems to be largely duespaceline-ml-main
.I've tried simplifying Spacemacs' theme options, disabling several packages, and it doesn't seem to help much.
By chance, one time I noticed a function with the name "centaur" in it was using a lot of CPU, so I disabled the package, and CPU dropped to below 1% (on average).
I'm not sure how to diagnose this from Emacs, beyond minimal things like running the profiler, and even then I'm not sure what to look at, there.
The text was updated successfully, but these errors were encountered: