-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
Completion menu show up time is long if a source is slow #645
Comments
Reproduced. |
diff --git a/rplugin/python3/deoplete/parent.py b/rplugin/python3/deoplete/parent.py
index 97cb510..b03ea7d 100644
--- a/rplugin/python3/deoplete/parent.py
+++ b/rplugin/python3/deoplete/parent.py
@@ -88,5 +88,5 @@ class Parent(logger.LoggingMixin):
return queue_id
def _get(self, queue_id):
- return [x for x in self._proc.communicate(40)
+ return [x for x in self._proc.communicate(0.02)
if x['queue_id'] == queue_id] Here is the patch for it. |
Thanks for the quick response, but it's a pity, this patch not works for me. Patch on deoplete diff --git a/rplugin/python3/deoplete/parent.py b/rplugin/python3/deoplete/parent.py
index 97cb510..b03ea7d 100644
--- a/rplugin/python3/deoplete/parent.py
+++ b/rplugin/python3/deoplete/parent.py
@@ -88,5 +88,5 @@ class Parent(logger.LoggingMixin):
return queue_id
def _get(self, queue_id):
- return [x for x in self._proc.communicate(40)
+ return [x for x in self._proc.communicate(0.02)
if x['queue_id'] == queue_id]
diff --git a/rplugin/python3/deoplete/source/tag.py b/rplugin/python3/deoplete/source/tag.py
index 1dcec7f..7a32695 100644
--- a/rplugin/python3/deoplete/source/tag.py
+++ b/rplugin/python3/deoplete/source/tag.py
@@ -33,6 +33,8 @@ class Source(Base):
self._make_cache(context)
def gather_candidates(self, context):
+ import time
+ time.sleep(10)
self._make_cache(context)
candidates = []
for c in self._cache.values(): Here is the new log file |
It works for me. |
I should use |
I have tested |
diff --git a/rplugin/python3/deoplete/deoplete.py b/rplugin/python3/deoplete/deoplete.py
index 0ce7e54..75f57fb 100644
--- a/rplugin/python3/deoplete/deoplete.py
+++ b/rplugin/python3/deoplete/deoplete.py
@@ -4,6 +4,8 @@
# License: MIT license
# ============================================================================
+from concurrent.futures import ThreadPoolExecutor
+
from deoplete import logger
from deoplete.parent import Parent
from deoplete.util import (error_tb, find_rplugins)
@@ -38,8 +40,9 @@ class Deoplete(logger.LoggingMixin):
context['rpc'] = 'deoplete_on_event'
# Init processes
+ self._executor = ThreadPoolExecutor(max_workers=4)
for n in range(0, self._max_parents):
- self._parents.append(Parent(vim, context))
+ self._parents.append(Parent(vim, context, self._executor))
if self._vim.vars['deoplete#_logging']:
for parent in self._parents:
parent.enable_logging()
diff --git a/rplugin/python3/deoplete/parent.py b/rplugin/python3/deoplete/parent.py
index 6dba494..a97e470 100644
--- a/rplugin/python3/deoplete/parent.py
+++ b/rplugin/python3/deoplete/parent.py
@@ -13,7 +13,7 @@ from deoplete.process import Process
class Parent(logger.LoggingMixin):
- def __init__(self, vim, context):
+ def __init__(self, vim, context, executor):
self.name = 'parent'
self._vim = vim
@@ -21,7 +21,7 @@ class Parent(logger.LoggingMixin):
self._child = None
self._queue_id = ''
self._prev_pos = []
- self._start_process(context)
+ self._start_process(context, executor)
def enable_logging(self):
self._put('enable_logging', [])
@@ -68,14 +68,14 @@ class Parent(logger.LoggingMixin):
if context['event'] == 'VimLeavePre':
self._stop_process()
- def _start_process(self, context):
+ def _start_process(self, context, executor):
if self._vim.vars['deoplete#num_processes'] > 1:
# Parallel
python3 = self._vim.vars.get('python3_host_prog', 'python3')
self._proc = Process(
[python3, context['dp_main'],
self._vim.vars['deoplete#_serveraddr']],
- context, context['cwd'])
+ context, context['cwd'], executor)
else:
# Serial
from deoplete.child import Child
diff --git a/rplugin/python3/deoplete/process.py b/rplugin/python3/deoplete/process.py
index 728f7fe..5bfc657 100644
--- a/rplugin/python3/deoplete/process.py
+++ b/rplugin/python3/deoplete/process.py
@@ -7,13 +7,12 @@
import subprocess
import os
import msgpack
-from threading import Thread
from queue import Queue
from time import time, sleep
class Process(object):
- def __init__(self, commands, context, cwd):
+ def __init__(self, commands, context, cwd, executor):
startupinfo = None
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
@@ -33,18 +32,16 @@ class Process(object):
encoding='utf-8',
unicode_errors='surrogateescape')
self._queue_out = Queue()
- self._thread = Thread(target=self.enqueue_output)
- self._thread.start()
+ self._future = executor.submit(self.enqueue_output)
def kill(self):
if not self._proc:
return
+ self._future.cancel()
self._proc.kill()
self._proc.wait()
self._proc = None
self._queue_out = None
- self._thread.join(1.0)
- self._thread = None
def enqueue_output(self):
while self._proc:
diff --git a/rplugin/python3/deoplete/source/tag.py b/rplugin/python3/deoplete/source/tag.py
index b407d03..88f2f9b 100644
--- a/rplugin/python3/deoplete/source/tag.py
+++ b/rplugin/python3/deoplete/source/tag.py
@@ -33,6 +33,8 @@ class Source(Base):
self._make_cache(context)
def gather_candidates(self, context):
+ import time
+ time.sleep(10)
self._make_cache(context)
candidates = []
for c in self._cache.values(): You can test the patch. |
nvim-completion-manager uses neovim event loop instead. |
I tried the patch on windows, it doesn't work on most time. |
|
Oh, concurrent.future version makes Vim exiting time will be slowly. |
I will test neovim/pynvim#294 and add support it later. |
neovim/pynvim#294 is merged. |
|
@Shougo Should I test it now? or maybe later |
I test now...
Result: No magic. |
@Shougo I'm sorry to hear that. |
I have fixed the problem. |
I have tested it in asyncio patch. |
https://gist.github.com/Shougo/b1292a539dcf7058c5e22b253fd46339 Note: It may not work in Windows environment. I think it is the faster implementation. |
The patch in gist was fail to apply on deoplete master
|
You should use |
I tried this patch on linux, it works for me. |
Yes. |
Got it, thanks! |
You can test neovim/pynvim#307 branch. |
neovim-python is upgrade to 0.2.4 which fix the windows issue. I enabled debug with
But only got nvim_log_py3_script, there is no deoplete.log. |
Yes. It is intended behavior. |
@Shougo Thanks for the information. 👍 |
Warning: I will close the issue without the minimal init.vim and the reproduction instructions.
Problems summary
I compared deoplete with ncm.
In ncm, if a source is slow, it will not impact the completion menu show up time.
But in ncm, if a source is slow, it will impact the completion menu show up time.
Expected
If some source is slow, the faster source should show in completion menu first.
Environment Information
deoplete version(SHA1):
c145a7f
OS:
windows 10
neovim/Vim version:
NVIM 0.2.2
:checkhealth
or:CheckHealth
result(neovim only):Provide a minimal init.vim/vimrc with less than 50 lines (Required!)
The reproduce ways from neovim/Vim starting (Required!)
gather_candidates()
tag.pyScreen shot (if possible)
Upload the log file
deoplete.log
The text was updated successfully, but these errors were encountered: