Skip to content
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

paused timers consume CPU #8188

Closed
andymass opened this issue Mar 26, 2018 · 1 comment
Closed

paused timers consume CPU #8188

andymass opened this issue Mar 26, 2018 · 1 comment
Labels
bug issues reporting wrong behavior event-loop
Milestone

Comments

@andymass
Copy link
Contributor

  • nvim --version: NVIM v0.2.2
  • Vim (version: ) behaves differently? Cannot reproduce in vim 8.1542
  • Operating system/version: Arch linux/recent
  • Terminal name/version: konsole/17.12.3
  • $TERM: xterm-256color

Steps to reproduce:

Here is an example init.vim:

set nocompatible

if 0     " toggle to enable vim-airline
	let &rtp  = '~/.config/nvim/bundle/vim-airline,' . &rtp
endif

filetype plugin indent on
syntax on 

function! CallBack(tid)
	echo 'callback'
endfunction

let g:timer = timer_start(10, 'Callback',
            \ {'repeat': -1})

call timer_pause(g:timer, 1)

nnoremap <space> :<c-u>call timer_stop(g:timer)<cr>

run:

nvim -u init.vim init.vim

and htop or similar.

This is probably related to: #7871, though that was primarily about a memory leak.

Actual behavior

  • Without vim-airline, neovim consumes 1%--2% CPU. Pressing space to stop the timer makes the CPU go to 0%.

  • With vim-airline, neovim consumes 10%--12% CPU. Again, pressing space makes the CPU go to 0%.

To emphasize, I am not claiming this is any bug in vim-airline, but the presence of vim-airline exacerbates the issue many-fold, which may help in determining the cause.

Expected behaviour

There should be no CPU activity when timers are paused. In vim, there is apparently no cost to having timers paused.

@justinmk justinmk added bug issues reporting wrong behavior event-loop labels Mar 26, 2018
@justinmk justinmk added this to the 0.3 milestone Mar 26, 2018
@bfredl
Copy link
Member

bfredl commented Mar 27, 2018

probably time_watcher_stop or time_watcher_start should be called in f_timer_paused (conditional on that the state actually changed).

@justinmk justinmk modified the milestones: 0.3, 0.2.3 Mar 29, 2018
justinmk pushed a commit that referenced this issue Mar 30, 2018
If the timer isn't stopped, it still emits events which consume some CPU.

Fix #8188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior event-loop
Projects
None yet
Development

No branches or pull requests

3 participants