goenv icon indicating copy to clipboard operation
goenv copied to clipboard

Seeing high CPU usage for `libexec/goenv-version-file`

Open FlorianLoch opened this issue 3 years ago • 1 comments
trafficstars

Hello, I am seeing the following in htop (but also in other places) havin goenv on my M1 MacBook:

goenv

That keeps basically running all the time, sometimes there is even more than one instances consuming multiple CPU cores.

Killing the process doesn't really help as it gets restarted.

goenv-version-file seems to get (re-)started by goenv-version-name which again gets started by goenv-sh-rehash --only-manage-paths. Following the chain further up probably isn't too helpful but it looks like goenv's initial invocation comes from zsh (probably looking for the current dir's Go version as I have enabled showing it in powerlevel10k), which gets started by some macOS system update component (which, indeed, seems to be stuck - so that would make sense).

Any idea why goenv-version-file keeps on searching without ever coming to an end?

FlorianLoch avatar Oct 19 '22 05:10 FlorianLoch

I don't exclude the possibility of this being a bug, I haven't personally hit it before. Hmm, do you have a bit more to show from your .zshrc? Looking for a loopy bootstrap logic.

Other than that I'm not a user of powerlevel10k, but I can check it out a bit. Seeing some interesting usage in https://github.com/romkatv/powerlevel10k/blob/master/internal/p10k.zsh#L4418

Also, can you set in your .zshrc export GOENV_DEBUG=1 so that you can gather and share logs such as

...
 [goenv-version-file:26] root=/home
+ [goenv-version-file:11] [[ /home =~ ^//[^/]*$ ]]
+ [goenv-version-file:12] '[' -e /home/.go-version ']'
+ [goenv-version-file:17] '[' -e /home/go.mod ']'
+ [goenv-version-file:22] '[' -z /home ']'
+ [goenv-version-file:26] root=
+ [goenv-version-file:11] [[ '' =~ ^//[^/]*$ ]]
+ [goenv-version-file:12] '[' -e /.go-version ']'
+ [goenv-version-file:17] '[' -e /go.mod ']'
+ [goenv-version-file:22] '[' -z '' ']'
+ [goenv-version-file:23] break
+ [goenv-version-file:28] return 1
+ [goenv-version-file:35] '[' /home/syndbg/.goenv '!=' /home/syndbg/.goenv ']'
+ [goenv-version-file:36] echo /home/syndbg/.goenv/version
...

syndbg avatar Oct 20 '22 22:10 syndbg