Shougo / denite.nvim

:dragon: Dark powered asynchronous unite all interfaces for Neovim/Vim8
Other
2.06k stars 215 forks source link

python and n/vim use high CPU time after denite usage. #865

Closed ikeji closed 2 years ago

ikeji commented 2 years ago

Problems summary

Sometime, vim and python process consume high CPU time. And I found it's happen after using denite plugin.

Expected

After close denite buffer, denite plugin doesn't consume CPU time.

Environment Information (Required!)

Provide a minimal init.vim with less than 50 lines (Required!)

set runtimepath+=~/path/to/vim.d/denite.nvim

autocmd FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
  nnoremap <silent><buffer><expr> <CR>
  \ denite#do_map('do_action')
endfunction

call denite#custom#alias('source', 'slow', 'file/rec')
call denite#custom#var('slow', 'command',
        \ ['slow'])

and slow command is this script

#!/usr/bin/env python
import time
import sys

for x in range(1000):
  print("{} hoge".format(x))
  sys.stdout.flush()
  time.sleep(0.01)

How to reproduce problems from neovim startup (Required!)

  1. open vim or nvim
  2. run this command: Denite -start-filter slow
  3. input 'hoge' to filter box and hit enter twice (one for confirm the filter and one for select a candidate). This step should be done in 10 second that before the 'slow' script is not finish.

The high CPU usage doesn't happen always, need to repeat few times for reproduce. In my machine, it happened in 1-3 times.

Upload the log file

I set NVIM_PYTHON_LOG_FILE=/tmp/log, but it generate /tmp/log_py4_rplugin only. does this the log that is required?

Here is a repeated part of log_py3_rplugin. https://gist.github.com/ikeji/a0f1d6329ef50801ef0601a116d4b6e0 Here is a entire log file. http://test.ikeji.ma/log_py3_rplugin (warning: 62MB)

Does anyone have any idea to avoid this?

Shougo commented 2 years ago

Unfortunately, I cannot fix the problem.

denite.nvim has CPU usage and the performance problem. You should use ddu.vim instead. https://github.com/Shougo/ddu.vim

Shougo commented 2 years ago

I think the process cannot be killed(ignored stop signal). If the CPU usage is high, it causes sometime. No magic.

ikeji commented 2 years ago

I think this is more like task leak instead of performance problem.

I found this command resolve CPU usage in python side, but Vim side is not. unlet g:denite#_channel_id

Shougo commented 2 years ago

If the Python task is heavy, Vim cannot quit the task. Because the signal is ignored. And the remote plugins has task cleanup problems. I gave up and move to denops.

Shougo commented 2 years ago

I have tested your example and I cannot reproduce it!

Shougo commented 2 years ago

I have changed the example. I will try it.

ikeji commented 2 years ago

Updated the script.

Shougo commented 2 years ago

Hi, I have updated denite.nvim. Please use the latest version.

ikeji commented 2 years ago

Thanks. I tested the new version and the bug is gone!

Thanks a lot!