-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
Insert mode lags #1165
Comments
Without a MWE there's no way to know what causes your issue. Bisect your config until you find one, then post it here. Here's what a MWE could look like:
See also reproducing-bugs. Just a guess, but in your gifs, the text contains fold markers; folding can introduce lag. |
Also, try to get a profile:
See |
That is not the case:
|
Ok, then you'll have to bisect your config to find a minimal reproducible example. |
Busy at work, will try to do it when I have time. Thx. |
Well, I've spent last 1.5 hour bisecting my config, removing/reinstalling plugins and couldn't find the exact thing that makes ultisnips slow. without any plugins installed next lines in my vimrc makes ultisnips slower (not THAT slow as in my previous gifs but I can see it):
When I start adding other plugins one by one, ultisnips become slightly more laggy with each plugin I install until the result u see in gifs. I couldn't find single plugin that adds all the laggines fo far. I think you can close the issue and reopen it when there will be other reports on it (I will continue using vsnip for now as I don't have time at the moment to investigate root cause) Thank you! |
This is very unfortunate behavior and I am deeply sorry that it bothered your editing experience. Windows support is traditionally the poorest in UltiSnips. The reason is that I do not have access to a Windows machine and have in fact not worked on any Windows machine for ten years or so. traditionally, the Python <-> Vim bridge in Windows was not very performant. My hunch (without any data) is that string conversions (Vim uses UTF8, while Windows traditionally uses Unicode 16 or so, which I think python on Windows also uses internally) are expensive and that could be the reason you see slow downs. However, I do not have the means to investigate this. I'll leave this open for a while to see if somebody else jumps on it and can add additional data. @habamax Thanks for investing so much time and energy into this bug report! |
Just wanted to say I have experienced this on both Linux and Windows. |
Indeed, i'm using ubuntu and I do have similar issue. |
I can confirm that I have the same issue on GVIM on Windows (but not on GVIM on KDE Linux, though). The lag is specially noticeable when editing text files (perhaps because I type prose much faster than code?) and creating a new snippet file for texts with :UltiSnipsEdit seems to alleviate the lag a little (any snippet will do, just need to create the file). |
Same issue for GVim+win10 |
I thought I found something, and figure out how to reproduce this on Linux. I am experiencing serious insert mode lag too: One thing I noticed is that: when I was using a minimal vimrc (with only one plugin, ultisnips installed), the lag was small, but still noticable. Then I started to add other plugins and found: the more plugin I had, the more input lag I got . Is it related to the number of set nocompatible
set ttimeout
set ttimeoutlen=50
set display=lastline
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,gbk,gb18030,big5,euc-jp,latin1
set showcmd
syntax enable
syntax on
filetype plugin indent on
set rtp+=c:/users/Linwei/.vim/bundles/ultisnips
let BASE = 'd:/temp/ultisnips'
for i in range(300)
let tmpname = printf("%s/rtp-%d", BASE, i)
exec 'set rtp+=' . fnameescape(tmpname)
call mkdir(tmpname, 'p')
endfor
setlocal ft=cpp The lag became intolerable with this minimal vimrc: And I've recorded a profile log for this:
see the most expensive function is ultisnips/autoload/UltiSnips.vim Lines 176 to 178 in 24a3ebb
This function is listening on ultisnips/plugin/UltiSnips.vim Lines 37 to 44 in 24a3ebb
This function will be called several times when I press a single letter, what does it do ? Will it scan all the runtimepaths ? Can it be removed ? or only add to I have 95+ plugins installed, which is normal nowadays, Windows I/O is slower than Linux, so this function made me unable to edit. @SirVer , I believe you can reproduce it too on Linux by just adding 300, or more, empty runtimepaths. |
@skywind3000 Thanks for investing time into this issue, I highly appreciate it. TrackChanges is doing a diff between the buffer as it was before the last cursor move and after the current cursor move. This is needed to understand how the buffer change to update tabstops, mirrors and therelike. It is a potentially very expensive function if the buffer has changed tremendously (e.g. if you paste a lot of text while a snippet is active), however it is surprising to me that it would depend on the runtime path. It also calls I think a bit more digging is required on your end - I cannot reproduce lag in simple buffers even with 300 entries in my runtimepath. Edit: to clarify: If I add 1000 directories to my rtp, i notice a clear lack upon expanding the first time the cursor moves, but not thereafter. |
I doubt this depends on the amount of paths in the rtp. But rather on the latency of the underlying filesystem. When using neovim inside a linux VM to edit files on a virtiofs mount, the delay while typing makes it barely usable. (With my snippets and plugins are also on this virtiofs mount). The only current workaround is to delete the augroup |
I do not get where this would come from though - UltiSnips does not access the filesystem unless reloading snippets, which only happens on the first expand or after a .snippet file was edited inside Vim. |
Ultisnips was traversing the whole runtimepath every time an expansion was attempted, something that happens for every key press since there is autotrigger. Even without autotrigger, traversal was done at every snippet expansion, which caused slowdowns in that case. With this change, traversal happens only the first time, or after a source must be refreshed (because a snippets file has been updated).
appreciated |
In insert mode I can see quite a lag especially when I do enter Russian letters.
Expected behavior:
Should be no lag
Actual behavior:
Lag
Steps to reproduce
Well, not sure. I just had it installed for quite a long time
Settings that I had regarding ultisnips
My snippets were:
https://github.com/habamax/.vim/tree/03dce7b57131e993b5ccdc88775196c2f5fe7ef6/UltiSnips
If I remove Ultisnips (use vsnips instead):
PS
If I remove
au! Ultisnips_AutoTrigger
it becomes way faster. But only for english. Russian lags the same.The text was updated successfully, but these errors were encountered: