-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Description
I'm profiling/debugging performance bottlenecks in the python client.
Two things stuck out so far.
Calls to BufferedFormatter in logging, when logging was disabled. This can be fixed by gating anydebug(),warn()etc calls behind anif _debugstatement as shown in asyncio.- (Edit: fixed, see below)
walk(to_nvim)andwalk(from_nvim)are extremely expensive calls on nested object trees. For example, if I have a 5000 line buffer and get/set the entire thing, these calls seem to account for at least 80% of the 20ms spent. I fixed this by adding the following functions on theRemoteandNvimclasses and invoking it forbuf_get_linesandbuf_set_linesinstead of request_raw:
class Remote:
def request_raw(self, name, *args, **kwargs):
return self._session.request_raw(name, self._session._to_nvim(self), *args, **kwargs)
class Nvim:
def request_raw(self, name, *args, **kwargs):
return self._session.request(name, *args, **kwargs)
Profiling data generated with yappi on Python 3.3 and my test script are attached.
after.txt
before.txt
import neovim
sample = ['a'] * 10000
def setup():
n = neovim.attach('child', argv=['/Users/aegis/build/neovim/build/bin/nvim', '--embed'])
buf = n.current.buffer
buf[:] = sample
return buf
def bufeq(buf):
buf[:] = sample
def eqbuf(buf):
_ = buf[:]
buf = setup()
for i in range(10):
bufeq(buf)
for i in range(10):
eqbuf(buf)
import sys
sys.exceptionhandler = lambda *a: 0
Metadata
Metadata
Assignees
Labels
No labels