
Careless plugin authors are creating serious issues with regard to CPU usage
I've just been down a rabbit hole using Gemini to analyze why my nvim setup is consuming so many CPU resources when idle. This is a huge issue - I could potentially have many instances of nvim open, and each one using up CPU cycles carelessly adds up to a serious waste of CPU cycles and heating. My laptop has been too hot for months, and now I finally know why.
The main culprit? Plugin authors are setting repeating timers of 33ms, 50ms or worse without realizing the implication - they're constantly waking up the CPU and turning sleep into effective busy waits.
So far I've found:
which-keysets a 50ms timer to bypass the lack of ModeChanged events on pre-0.10 Neovim. Completely unnecessary on 0.10+ and done without a version check.noicesets an indefinite 33ms timer on bootup.snacks' statuscolumn plugin runs a 50ms timer to refresh the status rather than responding to events.lualinesets a 50ms/16ms(!) timer by default.
All of these are included in Lazyvim, meaning that if you use Lazyvim, you've turned neovim into a CPU cycle-eating machine.
I don't want to keep hunting for high frequency timers in careless plugins. Something needs to be done, preferably at the nvim layer.
EDIT: Definitely didn't expect some people to be so defensive about this.
To clarify: timers aren't a problem in an application that already uses up your CPU a lot and needs to respond quickly. They are a problem in an application that sits in the background is supposed to let the CPU idle as much as possible. One can also run the timers when the app is active, and then disable them when it's idling. I have neovim running in tens of instances on my machines, and the impact is serious.
I'm attaching LLM answers as objective observers on the matter, since people want to dispute it:
https://chatgpt.com/share/6a4a2354-03e4-83ed-b745-2315e3b3e88f
https://share.gemini.google/vAll2XerOoso
https://claude.ai/share/95cec7cb-7078-4bd9-91c1-6f2f2009a325
EDIT2: I didn't mean this as an attack on anyone in particular (even if it was read as such), and I didn't do my homework enough to know 3 of the mentioned plugins are made by one guy, making it look like an attack. Seriously, this wasn't meant as a shaming or anything like that, no matter what intent you read into it. It's totally ok for any programmer to make this mistake - especially one as prolific as folke, and I appreciate his work greatly -- that's why I use it as my daily driver. My comment was meant at the problem where there is a lack of awareness in general about the problem of using high frequency timers, and there's no easy mechanism to trace them from the neovim side.