zinit
zinit copied to clipboard
[bug]: Constant CPU usage
What happened?
Hello, I noticed with even just a plain zinit .zshrc, around 0.7% per shell is used; this increases with more plugins.
Steps to reproduce
-
.zshrc
with contents:
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
source "${ZINIT_HOME}/zinit.zsh"
Relevant output
No response
Screenshots and recordings
Zinit with no plugins:
Zinit with plugins:
zsh -df
:
Operating System & Version
OS: linux-gnu | Vendor: unknown | Machine: x86_64 | CPU: x86_64 | Processor: unknown | Hardware: x86_64
Zsh version
zsh 5.9 (x86_64-unknown-linux-gnu)
Terminal emulator
alacritty
If using WSL on Windows, which version of WSL
No response
Additional context
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
~And what is the CPU usage without Zinit?~
Didn't see the last picture
I've hunted down this code that I will investigate.
It seems to be constantly running in the background
I see the same behavior, CPU usage without zinit for a zsh shell on my end is 0. With zinit is high, the same pattern reported by @mustaqimM. The constant CPU usage stops when an application is run in zsh shell, for instance vim/nvim. On my end the idle CPU usage of vim/nvim is 0. So keeping vim/nvim instance open in a zsh shell has lower overall CPU activity than keeping the shell at prompt waiting for user input.
@vladdoster How did you hunt that down? Any tool/methodology or commenting different parts of code?
@reportaman Noted. Thanks for the information!
I've finally got some time to dig into this tonight and over Labor day weekend.
To answer your questions:
I started a new Zsh instance with debugging via:
exec zsh --interactive --login --verbose --xtrace
and saw this output over and over when idle.
There is another tool I like for debugging, but will be cumbersome/frustrating to use if you aren't super familiar with using a debugger. That said, observability is useful even if you're just debugging your personal ZSH configuration.
https://zshdb.readthedocs.io/en/latest/
Have a feeling this is related to #315?
This can be lowered down by making scheduler sleep for a longer time like 5 seconds. It currently sleeps for 1 second.
wt., 1 lis 2022, 12:46 użytkownik vladislav doster @.***> napisał:
Have a feeling this is related to #315 https://github.com/zdharma-continuum/zinit/issues/315?
— Reply to this email directly, view it on GitHub https://github.com/zdharma-continuum/zinit/issues/362#issuecomment-1298399159, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOE4CHR3PYJZ6K72GHLRJLWGD7KXANCNFSM567OJ6QA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@psprint whats the reason for running the scheduler so often?
It's for wait ice - it's checked every second to run tasks in proper time slots. I guess that it could be changed to sleep for exactly the needed time or to sleep longer after e.g. fitst 5 seconds.
czw., 3 lis 2022, 01:15 użytkownik vladislav doster < @.***> napisał:
@psprint https://github.com/psprint whats the reason for running the scheduler so often?
— Reply to this email directly, view it on GitHub https://github.com/zdharma-continuum/zinit/issues/362#issuecomment-1301513181, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOE4CHR6JPFHQ3Y5S4W5T3WGL7ZLANCNFSM567OJ6QA . You are receiving this because you were mentioned.Message ID: @.***>
@vladdoster: the fix is in #409.
Can it be event based, or can a user use zinit in a way to avoid this loop altogether? It might look like low overhead, but that's subjective. At the moment an idle zsh shell with zinit installed executes 2 million+ aarch64 instructions per second on my computer. A power user who has tens of shell sessions on over time would see battery dipping... Or if someone were to port their zshrc to something like raspberry pi or other smaller computers they will have to get rid of zinit.
Can it be event based, or can a user use zinit in a way to avoid this loop altogether? It might look like low overhead, but that's subjective. At the moment an idle zsh shell with zinit installed executes 2 million+ aarch64 instructions per second on my computer. A power user who has tens of shell sessions on over time would see battery dipping... Or if someone were to port their zshrc to something like raspberry pi or other smaller computers they will have to get rid of zinit.
Yes the fix is in #409, @poetaman . It changes the sleep time to 10 seconds and makes a short circuit exit if no tasks.