zsh at 100% CPU #24

Closed
lucas-clemente opened this Issue Apr 16, 2014 · 11 comments
@lucas-clemente

After setting up autosuggestions every zsh shell process is taking up 100% CPU after using suggestions once. From my zshrc:

source ~/.zsh-autosuggestions/autosuggestions.zsh
export AUTOSUGGESTION_HIGHLIGHT_COLOR='fg=248'
bindkey '^F' forward-word
zle-line-init() {
  zle autosuggest-start
}
zle -N zle-line-init

zsh:

$ zsh --version
zsh 5.0.5 (x86_64-apple-darwin13.0.2)

Let me know if I can help.

@ajkaanbal

I've the same issue.
zsh 5.0.5 (x86_64-redhat-linux-gnu)

ltrace return a loop of this:

strcpy(0xc37860, "autosuggest-pop-suggestion")                = 0xc37860
strlen("")                                                    = 0
strlen("3")                                                   = 1
malloc(2)                                                     = 0xaa31f0
strcpy(0xaa31f0, "3")                                         = 0xaa31f0
strcmp("where-is", "autosuggest-pop-suggestion")              = 22
free(0xaa31f0)                                                = <void>
free(0xc37860)                                                = <void>
free(0xc36b50)                                                = <void>
sigemptyset(<>)                                               = 0
sigaddset(<27>, SIGWINCH)                                     = 0
sigprocmask(SIG_BLOCK, <27>, <27>)                            = 0
sigemptyset(<>)                                               = 0
sigaddset(<27>, SIGWINCH)                                     = 0
sigprocmask(0, <27>, <>)                                      = 0
malloc(16)                                                    = 0xc36b50
strlen("autosuggest-pop-suggestion")                          = 26
malloc(27)                                                    = 0xc37860
strcpy(0xc37860, "autosuggest-pop-suggestion")                = 0xc37860
strlen("")                                                    = 0
strlen("3")                                                   = 1
malloc(2)                                                     = 0xaa31f0
strcpy(0xaa31f0, "3")                                         = 0xaa31f0
strcmp("where-is", "autosuggest-pop-suggestion")              = 22
free(0xaa31f0)                                                = <void>
free(0xc37860)                                                = <void>
free(0xc36b50)                                                = <void>
sigemptyset(<>)                                               = 0
sigaddset(<27>, SIGWINCH)                                     = 0
sigprocmask(SIG_BLOCK, <27>, <27>)                            = 0
sigemptyset(<>)                                               = 0
sigaddset(<27>, SIGWINCH)                                     = 0
sigprocmask(0, <27>, <>)                                      = 0
malloc(16)                                                    = 0xc36b50
strlen("autosuggest-pop-suggestion")                          = 26
malloc(27)                                                    = 0xc37860
strcpy(0xc37860, "autosuggest-pop-suggestion")                = 0xc37860
strlen("")                                                    = 0
strlen("3")                                                   = 1
malloc(2)                                                     = 0xaa31f0
strcpy(0xaa31f0, "3")                                         = 0xaa31f0
strcmp("where-is", "autosuggest-pop-suggestion")              = 22
free(0xaa31f0)                                                = <void>
free(0xc37860)                                                = <void>
free(0xc36b50)                                                = <void>
sigemptyset(<>)                                               = 0
sigaddset(<27>, SIGWINCH)                                     = 0

and strace:

poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0
@jimhester

I get this as well, but only if I am running within tmux. It works fine without tmux.

@AndreyAntipov

I've same problem — process is taking up 100% CPU
zsh 5.0.5 (x86_64-apple-darwin14.0)

@forgottenleaf

I'm getting this too.

@balta2ar

Confirming, I have the same problem.
zsh 5.0.5 (x86_64-unknown-linux-gnu)

@tarruda

Sorry for the inactivity guys, I'm aware of this bug with zsh 5 but still didn't have time to look into it

@Mic92

My current workaround is to disable the autosuggest-server:

#if is-at-least 5.0.3; then
##  autosuggest-ensure-server
##fi

It seams not be an issue at all with zsh 5, but the server

@jimhester

Looking into this a little bit it looks like autosuggest-ensure-server is just broken, and the reason this problem only shows up in zsh > 5 is that the place that function is called is in an if statement which is only true for zsh > 5.0.3.

As @Mic92 said, the solution is to comment out those lines. Note this does not disable the autosuggest-server, just disables the extra check to ensure it is running (which seems to be unnecessary). I have not noticed any missing functionality from doing this.

@tarruda

As @Mic92 said, the solution is to comment out those lines. Note this does not disable the autosuggest-server, just disables the extra check to ensure it is running (which seems to be unnecessary). I have not noticed any missing functionality from doing this.

The server was created to asynchronously provide autosuggestions from user completion functions(right now it only uses history), which could be slow. Zsh 4 had some limitations that blocked this server from functioning properly, but this may have been fixed in zsh 5. The mailing list thread where I announced this plugin contains more information: http://www.zsh.org/mla/users/2013/msg00546.html

So I ended up adding a version check to only enable the server in Zsh 5, but unfortunately I didn't have the time to test or fix it(I'm still using zsh4). I will push a fix that disables the server until I find the time to look into it.

@algking

same issue ,problem solved.

@bjcerveny bjcerveny referenced this issue in robbyrussell/oh-my-zsh Oct 21, 2014
Closed

Yosemite's zsh CPU process at 100% #3247

@cskeeters

Thanks for the temporary fix tarruda. I did a "git pull" and my problem was solved after restarting zsh.

@faceleg faceleg closed this Dec 9, 2014
@JodiWarren JodiWarren referenced this issue in sorin-ionescu/prezto May 15, 2015
Closed

ZSH using 95-99% CPU on OSX 10.10/Yosemite #879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment