Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Significant delay when exiting from vim8 #52

Closed
liuchengxu opened this issue Mar 12, 2017 · 15 comments
Closed

Significant delay when exiting from vim8 #52

liuchengxu opened this issue Mar 12, 2017 · 15 comments

Comments

@liuchengxu
Copy link

There is a bit of lag when exiting from vim.

@roxma
Copy link
Owner

roxma commented Mar 12, 2017

two main causes:

  1. vim-hug-neovim-rpc uses multithread implementation. Vim has to wait for thread exit before shutdown, even if those are python daemon thread.
  2. The current version of NCM is using the classic multi-process architecture, it runs outside of vim process and it is started via the job_start function. However, the job_start method provided by vim8, unlike the jobstart in neovim, has no detach option available, which means vim8 has to wait for NCM process exit before shutdown.

I'll leave this issue open, and document this as known issue.

roxma added a commit that referenced this issue Mar 12, 2017
@roxma roxma changed the title Delay in exiting from vim Significant delay when exiting from vim8 Mar 12, 2017
@roxma roxma added the no-plan label Jun 24, 2017
@roxma
Copy link
Owner

roxma commented Oct 14, 2017

There's a daemon flag I missed to set for some of the threads.

I managed to fix this issue. It runs more smoothly now.

@liuchengxu
Copy link
Author

liuchengxu commented Oct 15, 2017

@roxma Thanks for your effort! But I run into an error in Vim8. Can you take a look at it?

ncm

Here is nvim.log_py3_cm_core

@roxma
Copy link
Owner

roxma commented Oct 15, 2017

Is there a minimal vimrc as bellow so that I can start with:

set nocompatible
syntax on
filetype plugin indent on
set encoding=utf-8 fileencodings=ucs-bom,utf-8,gbk,gb18030,latin1 termencoding=utf-8

call plug#begin(expand('<sfile>:h') . '/plugged/')
Plug 'roxma/nvim-completion-manager'
if !has('nvim')
    Plug 'roxma/vim-hug-neovim-rpc'
endif
call plug#end()

Besides, It seems vim-hug-neovim-rpc is not working. In this case, use NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=DEBUG vim8 for starting vim8, to generate the log file nvim.log_py2_neovim_rpc_server

I've just fixed a python2 issue on vim-hug-neovim-rpc. Remember to update both plugin to the latest version before further testing.

@liuchengxu
Copy link
Author

liuchengxu commented Oct 15, 2017

The minimal vimrc:

set nocompatible
syntax on
filetype plugin indent on
set encoding=utf-8 fileencodings=ucs-bom,utf-8,gbk,gb18030,latin1 termencoding=utf-8

call plug#begin('/tmp/plugged')
  Plug 'roxma/nvim-completion-manager'
  if !has('nvim')
    Plug 'roxma/vim-hug-neovim-rpc'
  endif
call plug#end()
$ export NVIM_PYTHON_LOG_FILE=nvim.log NVIM_PYTHON_LOG_LEVEL=DEBUG vim8
$ vim -U NONE -u vimrc

There are three logs generated(see here):

  • nvim.log_py3_cm_core
  • nvim.log_py3_neovim_rpc_server
  • nvim.log_py3_script

The error still persists in Vim8. NeoVim just works well.

@roxma
Copy link
Owner

roxma commented Oct 15, 2017

I cannot reproduce it.

But notice that similar error could be triggered by tee | vim | tee

[roxma@roxma-pc ~]$ tee | /usr/bin/vim | tee                                                                                                                                                        
Vim: Warning: Output is not to a terminal                                                                                                                                                           
Vim: Warning: Input is not from a terminal                                                                                                                                                          

Maybe part of the plugin is trying to start vim.

In this case, try export NVIM_NCM_MULTI_THREAD=0

Enter vim8, wait for the error, do nothing, open another terminal, check the process tree with something like ps --forest

@liuchengxu
Copy link
Author

The issue doesn't show up by setting export NVIM_NCM_MULTI_THREAD=0, in which case, NCM works fine in Vim8 and the previous delay problem goes away too.

Is the issue above only related to my local environment from your point of view? Does NVIM_NCM_MULTI_THREAD=0 make a difference to the user experience?

@roxma
Copy link
Owner

roxma commented Oct 15, 2017

The issue doesn't show up by setting export NVIM_NCM_MULTI_THREAD=0

I think it's printing internally, but the message fails to forward to NCM core and than forward to vim.

You could try inspect the process tree anyway.

Is the issue above only related to my local environment from your point of view?

I think it is.

Does NVIM_NCM_MULTI_THREAD=0 make a difference to the user experience?

Generally peaking, a user cannot feel the difference.

NVIM_NCM_MULTI_THREAD=1 means each source is running as a thread, this mode consumes less memory

NVIM_NCM_MULTI_THREAD=0 means each source is running as a process, this mode is easier for debugging.

@liuchengxu
Copy link
Author

liuchengxu commented Oct 15, 2017

Sorry, @roxma . Just realized that my last feedback (works in Vim8 using NVIM_NCM_MULTI_THREAD=0) was wrong 🙉 . I forgot to use the minimal vimrc :(. The right one should be as follows:

$ export NVIM_NCM_MULTI_THREAD=0
$ vim -U NONE -u vimrc

2017-10-15 2 04 08

Any tips?

@roxma
Copy link
Owner

roxma commented Oct 15, 2017

We're getting close, check the output of these commands

:python3 import sys
:python3 print(sys.executable)
:echo g:_cm_py3

@roxma
Copy link
Owner

roxma commented Oct 15, 2017

If the last two commands prints the wrong result, a workaround would be let g:python3_host_prog="python3"

@liuchengxu
Copy link
Author

liuchengxu commented Oct 15, 2017

:python3 import sys
:python3 print(sys.executable)
/usr/local/bin/vim
:echo g:_cm_py3
/usr/local/bin/vim

Not sure whether it's the wrong result, but Vim8 gets to work finally via let g:python3_host_prog="python3" in the minimal vimrc 🎉 .

@liuchengxu
Copy link
Author

For Vim 8:

  • roxma/vim-hug-neovim-rpc
  • g:python3_host_prog or python3 in your $PATH

I notice the requirement for Vim8 in README. I believe python3 has already been in $PATH in my case, but I still have to set g:python3_host_prog. So, may it's not complete to have only python3 in $PATH, or we could have a better instruction?

@roxma
Copy link
Owner

roxma commented Oct 16, 2017

The requirements are updated after this issue is figured out.

Have you updated both plugins to the latest version?

roxma added a commit to roxma/vim-hug-neovim-rpc that referenced this issue Oct 16, 2017
@liuchengxu
Copy link
Author

liuchengxu commented Oct 16, 2017

With the latest version and :echo has('python3') not empty, there is no need to set g:python3_host_prog! 🎉

roxma added a commit that referenced this issue Oct 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants