So I've seen most of the suggestions for speeding up Ruby and Vim specifically and I've implemented almost all of them. But what ended up having the most impact was actually removing this plugin. I profile about 5 seconds of editing a ruby file the results are below.
I'm not sure if this is specific to Ruby either. I know Ruby syntax and Vim have some problems so the lag might not be apparent for other languages.
Could there have been something wrong with my setup?
These were my settings in my vimrc:
let g:tmuxline_powerline_separators = 0
let g:airline_powerline_fonts = 1
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
140 1.643515 0.010460 airline#check_mode()
137 1.624063 0.442040 airline#highlighter#highlight()
3180 0.781071 0.087049 <SNR>130_exec_separator()
6360 0.595579 0.039114 airline#themes#get_highlight()
6360 0.556465 0.169649 airline#highlighter#get_highlight()
16820 0.505013 airline#highlighter#exec()
12720 0.337023 <SNR>130_get_syn()
6360 0.049793 <SNR>130_get_array()
81 0.029855 0.003674 airline#extensions#hunks#get_hunks()
81 0.026181 0.001598 <SNR>123_get_hunks()
81 0.024583 0.000711 <SNR>123_get_hunks_gitgutter()
81 0.023482 0.000521 <SNR>123_is_branch_empty()
162 0.023343 0.001074 airline#extensions#branch#head()
1 0.022072 0.000313 <SNR>124_get_git_untracked()
137 0.008992 0.003374 airline#highlighter#highlight_modified_inactive()
81 0.005991 0.004805 airline#extensions#whitespace#check()
1 0.003336 0.000427 GetRubyIndent()
744 0.003168 airline#util#wrap()
324 0.002638 airline#util#append()
37 0.002437 <SNR>106_Highlight_Matching_Pair()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
16820 0.505013 airline#highlighter#exec()
137 1.624063 0.442040 airline#highlighter#highlight()
12720 0.337023 <SNR>130_get_syn()
6360 0.556465 0.169649 airline#highlighter#get_highlight()
3180 0.781071 0.087049 <SNR>130_exec_separator()
6360 0.049793 <SNR>130_get_array()
6360 0.595579 0.039114 airline#themes#get_highlight()
140 1.643515 0.010460 airline#check_mode()
81 0.005991 0.004805 airline#extensions#whitespace#check()
81 0.029855 0.003674 airline#extensions#hunks#get_hunks()
137 0.008992 0.003374 airline#highlighter#highlight_modified_inactive()
744 0.003168 airline#util#wrap()
324 0.002638 airline#util#append()
37 0.002437 <SNR>106_Highlight_Matching_Pair()
140 0.001754 airline#statusline()
140 0.001641 airline#parts#ffenc()
81 0.026181 0.001598 <SNR>123_get_hunks()
5 0.001531 <SNR>156_IsInStringOrComment()
81 0.001702 0.001320 airline#extensions#branch#get_head()
1 0.001186 <SNR>125_check_mixed_indent()
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 19 2016 18:00:08)
MacOS X (unix) version
Included patches: 1-1090
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +cindent +conceal +digraphs +farsi -gettext +libcall +mksession +mouse_netterm -mzscheme +profile +scrollbind +syntax +textobjects +visualextra -X11
+arabic -clientserver +cryptv -dnd +file_in_path -hangul_input +linebreak +modify_fname +mouse_sgr +netbeans_intg +python +signs +tag_binary +title +viminfo -xfontset
+autocmd +clipboard +cscope -ebcdic +find_in_path +iconv +lispindent +mouse -mouse_sysmouse +path_extra -python3 +smartindent +tag_old_static -toolbar +vreplace -xim
-balloon_eval +cmdline_compl +cursorbind +emacs_tags +float +insert_expand +listcmds -mouseshape +mouse_urxvt +perl +quickfix -sniff -tag_any_white +user_commands +wildignore -xsmp
-browse +cmdline_hist +cursorshape +eval +folding +jumplist +localmap +mouse_dec +mouse_xterm +persistent_undo +reltime +startuptime -tcl +vertsplit +wildmenu -xterm_clipboard
++builtin_terms +cmdline_info +dialog_con +ex_extra -footer +keymap +lua -mouse_gpm +multi_byte +postscript +rightleft +statusline +terminfo +virtualedit +windows -xterm_save
+byte_offset +comments +diff +extra_search +fork() +langmap +menu -mouse_jsbterm +multi_lang +printer +ruby -sun_workshop +termresponse +visual +writebackup -xpm
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -F/usr/local/Frameworks -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -DMACOS_X_UNIX -Os -w -pipe -march=native -mmacosx-version-min=10.11 -isysroot /Applications/Xcode.app/Contents/Developer/
Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang -L. -L/Users/uri/.rbenv/versions/2.2.3/lib -fstack-protector -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -o vim -lm -lncurses
-liconv -framework Cocoa -L/usr/local/lib -llua -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -F/usr/local/Cellar/python/2.7.11/Frameworks -framework Python -lruby-static -framework CoreFoundation -lgmp -lobjc -L/Users/uri/.rbenv/versions/2.2.3/lib
_Will edit this in once I get some time to try it._
what is your .vimrc? Also, ruby syntax is known to be slow, does it work better if you do :syntax off
also I am really wondering, what you did in 5 seconds, that
137 1.624063 0.442040 airline#highlighter#highlight()
has been called 137 times...
see vim-ruby/vim-ruby#243
I've seen a lot of threads on how to improve ruby performance and have implemented most of them: explicitly setting the correct ruby path, using an older regex engine, turning folds off, turning cursorline off, setting ttyfast, setting lazydraw.
also I am really wondering, what you did in 5 seconds, that
These are the exact keystrokes I did after starting the profiling:
ithis is a test<esc>:profile pause
I will try to post my vimrc soon.
Have you tried syntax off?
I just checked with a random ruby file. Can't reproduce it. Have you other plugins running? Or perhaps cursorline or relativenumber setting set? Also did this just happen recently? If yes, can you please bisect, which commit did cause this?
I won't be able to bisect, I haven't been doing a good job at committing changes to my vimrc.
Here is my vimrc with airline: https://github.com/uri/vim/blob/airline/vimrc
I also reran the profile with that exact vimrc:
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
26 0.034595 0.001957 airline#check_mode()
2 0.032194 0.004670 airline#highlighter#highlight()
164 0.023700 0.006960 airline#highlighter#exec()
212 0.014380 0.004243 airline#highlighter#get_highlight()
424 0.008623 <SNR>143_get_syn()
24 0.007688 0.000704 <SNR>143_exec_separator()
1148 0.005576 <SNR>143_Get()
1 0.004706 0.000523 GetRubyIndent()
48 0.003507 0.000291 airline#themes#get_highlight()
26 0.002775 0.001369 airline#extensions#hunks#get_hunks()
35 0.002670 <SNR>106_Highlight_Matching_Pair()
8 0.002350 <SNR>119_IsInStringOrComment()
2 0.001950 0.000108 <SNR>119_PrevNonBlankNonString()
26 0.001898 airline#extensions#whitespace#check()
212 0.001514 <SNR>143_get_array()
1 0.001492 0.000217 <SNR>119_GetMSL()
26 0.001406 0.000621 <SNR>136_get_hunks()
1 0.001006 0.000498 <SNR>119_ExtraBrackets()
104 0.000988 airline#util#append()
182 0.000856 airline#util#wrap()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
424 0.008623 <SNR>143_get_syn()
164 0.023700 0.006960 airline#highlighter#exec()
1148 0.005576 <SNR>143_Get()
2 0.032194 0.004670 airline#highlighter#highlight()
212 0.014380 0.004243 airline#highlighter#get_highlight()
35 0.002670 <SNR>106_Highlight_Matching_Pair()
8 0.002350 <SNR>119_IsInStringOrComment()
26 0.034595 0.001957 airline#check_mode()
26 0.001898 airline#extensions#whitespace#check()
212 0.001514 <SNR>143_get_array()
26 0.002775 0.001369 airline#extensions#hunks#get_hunks()
104 0.000988 airline#util#append()
182 0.000856 airline#util#wrap()
15 0.000799 <SNR>119_Match()
24 0.007688 0.000704 <SNR>143_exec_separator()
26 0.001406 0.000621 <SNR>136_get_hunks()
18 0.000617 <SNR>139_update()
1 0.004706 0.000523 GetRubyIndent()
26 0.000639 0.000499 airline#extensions#branch#get_head()
1 0.001006 0.000498 <SNR>119_ExtraBrackets()
This was me just opening a single file and doing the same actions I did for the previous profile. Perhaps the difference in running times can be caused by how many buffers I had going?
that does not look as bad as your original report.
I won't be able to bisect, I haven't been doing a good job at committing changes to my vimrc.
What I meant, was not to bisect your vim configuration, but rather to bisect vim-airline, to find out, which vim-airline plugin causes this.
I experience the same problem
FUNCTIONS SORTED ON TOTAL TIME
COUNT TOTAL (S) SELF (S) FUNCTION
87 0.669417 0.007493 AIRLINE#CHECK_MODE()
81 0.656712 0.213546 AIRLINE#HIGHLIGHTER#HIGHLIGHT()
1134 0.263876 0.033891 <SNR>125_EXEC_SEPARATOR()
7227 0.217556 AIRLINE#HIGHLIGHTER#EXEC()
2268 0.194731 0.015376 AIRLINE#THEMES#GET_HIGHLIGHT()
2268 0.179355 0.054486 AIRLINE#HIGHLIGHTER#GET_HIGHLIGHT()
4536 0.106180 <SNR>125_GET_SYN()
42 0.045551 ULTISNIPS#TRACKCHANGE()
2268 0.018689 <SNR>125_GET_ARRAY()
87 0.008803 0.004221 AIRLINE#EXTENSIONS#HUNKS#GET_HUNKS()
87 0.007049 0.000822 AIRLINE#EXTENSIONS#SYNTASTIC#GET_WARNINGS()
87 0.006227 0.000700 SYNTASTICSTATUSLINEFLAG()
87 0.005357 0.004933 AIRLINE#EXTENSIONS#WHITESPACE#CHECK()
81 0.005212 0.002200 AIRLINE#HIGHLIGHTER#HIGHLIGHT_MODIFIED_INACTIVE()
87 0.004821 308()
87 0.004582 0.001858 <SNR>118_GET_HUNKS()
696 0.003084 AIRLINE#UTIL#WRAP()
348 0.002992 AIRLINE#UTIL#APPEND()
43 0.002919 <SNR>96_HIGHLIGHT_MATCHING_PAIR()
87 0.002851 0.001137 AIRLINE#EXTENSIONS#TAGBAR#CURRENTTAG()
FUNCTIONS SORTED ON SELF TIME
COUNT TOTAL (S) SELF (S) FUNCTION
7227 0.217556 AIRLINE#HIGHLIGHTER#EXEC()
81 0.656712 0.213546 AIRLINE#HIGHLIGHTER#HIGHLIGHT()
4536 0.106180 <SNR>125_GET_SYN()
2268 0.179355 0.054486 AIRLINE#HIGHLIGHTER#GET_HIGHLIGHT()
42 0.045551 ULTISNIPS#TRACKCHANGE()
1134 0.263876 0.033891 <SNR>125_EXEC_SEPARATOR()
2268 0.018689 <SNR>125_GET_ARRAY()
2268 0.194731 0.015376 AIRLINE#THEMES#GET_HIGHLIGHT()
87 0.669417 0.007493 AIRLINE#CHECK_MODE()
87 0.005357 0.004933 AIRLINE#EXTENSIONS#WHITESPACE#CHECK()
87 0.004821 308()
87 0.008803 0.004221 AIRLINE#EXTENSIONS#HUNKS#GET_HUNKS()
696 0.003084 AIRLINE#UTIL#WRAP()
348 0.002992 AIRLINE#UTIL#APPEND()
43 0.002919 <SNR>96_HIGHLIGHT_MATCHING_PAIR()
81 0.005212 0.002200 AIRLINE#HIGHLIGHTER#HIGHLIGHT_MODIFIED_INACTIVE()
87 0.004582 0.001858 <SNR>118_GET_HUNKS()
87 0.001553 AIRLINE#STATUSLINE()
87 0.001865 0.001433 AIRLINE#EXTENSIONS#BRANCH#GET_HEAD()
87 0.002851 0.001137 AIRLINE#EXTENSIONS#TAGBAR#CURRENTTAG()
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 20 2015 17:25:59)
MacOS X (unix) version
Included patches: 1-922
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +comments +ex_extra +jumplist -mouseshape +path_extra +signs +textobjects +writebackup
+arabic +conceal +extra_search +keymap +mouse_dec +perl +smartindent +title -X11
+autocmd +cryptv +farsi +langmap -mouse_gpm +persistent_undo -sniff -toolbar -xfontset
-balloon_eval +cscope +file_in_path +libcall -mouse_jsbterm +postscript +startuptime +user_commands -xim
-browse +cursorbind +find_in_path +linebreak +mouse_netterm +printer +statusline +vertsplit -xsmp
++builtin_terms +cursorshape +float +lispindent +mouse_sgr +profile -sun_workshop +virtualedit -xterm_clipboard
+byte_offset +dialog_con +folding +listcmds -mouse_sysmouse +python +syntax +visual -xterm_save
+cindent +diff -footer +localmap +mouse_urxvt -python3 +tag_binary +visualextra -xpm
-clientserver +digraphs +fork() -lua +mouse_xterm +quickfix +tag_old_static +viminfo
+clipboard -dnd -gettext +menu +multi_byte +reltime -tag_any_white +vreplace
+cmdline_compl -ebcdic -hangul_input +mksession +multi_lang +rightleft -tcl +wildignore
+cmdline_hist +emacs_tags +iconv +modify_fname -mzscheme +ruby +terminfo +wildmenu
+cmdline_info +eval +insert_expand +mouse +netbeans_intg +scrollbind +termresponse +windows
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang -L. -L/usr/local/lib -L/usr/local/lib -Wl,-headerpad_max_install_names -o vim -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python -lruby.2.0.0 -lobjc
I removed and reinstalled all vim plugins and the lagginess has gone.
Any update here?
I am experiencing the lag as well.
Editing large ruby files makes it worse, to the point of rendering vim unusable.
This should probably be escalated to bug status.
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
21 0.030769 0.001706 airline#check_mode()
3 0.028820 0.008551 airline#highlighter#highlight()
53 0.014138 0.001721 <SNR>159_exec_separator()
106 0.010672 0.000756 airline#themes#get_highlight()
110 0.010242 0.003133 airline#highlighter#get_highlight()
281 0.008697 airline#highlighter#exec()
220 0.005798 <SNR>159_get_syn()
21 0.004884 0.000324 airline#extensions#tagbar#currenttag()
10 0.004560 0.000564 tagbar#currenttag()
10 0.003508 0.003399 <SNR>188_GetNearbyTag()
10 0.002671 0.000372 airline#extensions#tabline#get()
10 0.002299 0.000317 airline#extensions#tabline#buffers#get()
21 0.001886 0.000220 airline#extensions#syntastic#get_warnings()
1 0.001709 0.000283 397()
11 0.001674 0.000179 airline#extensions#tabline#get_buffer_name()
21 0.001666 0.000159 SyntasticStatuslineFlag()
11 0.001428 0.001193 airline#extensions#tabline#formatters#default#format()
110 0.001311 <SNR>159_get_array()
21 0.001275 310()
21 0.001103 0.000546 airline#extensions#hunks#get_hunks()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
281 0.008697 airline#highlighter#exec()
3 0.028820 0.008551 airline#highlighter#highlight()
220 0.005798 <SNR>159_get_syn()
10 0.003508 0.003399 <SNR>188_GetNearbyTag()
110 0.010242 0.003133 airline#highlighter#get_highlight()
53 0.014138 0.001721 <SNR>159_exec_separator()
21 0.030769 0.001706 airline#check_mode()
110 0.001311 <SNR>159_get_array()
21 0.001275 310()
11 0.001428 0.001193 airline#extensions#tabline#formatters#default#format()
21 0.000999 airline#extensions#whitespace#check()
84 0.000811 airline#util#append()
168 0.000785 airline#util#wrap()
106 0.010672 0.000756 airline#themes#get_highlight()
10 0.004560 0.000564 tagbar#currenttag()
21 0.001103 0.000546 airline#extensions#hunks#get_hunks()
21 0.000596 0.000465 airline#extensions#branch#get_head()
21 0.000557 0.000449 <SNR>147_get_hunks()
10 0.002671 0.000372 airline#extensions#tabline#get()
3 0.000338 <SNR>124_Highlight_Matching_Pair()
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 27 2016 20:14:42)
MacOS X (unix) version
Included patches: 1-1401
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+channel -gettext -mzscheme +textobjects
+cindent -hangul_input +netbeans_intg +title
-clientserver +iconv +packages -toolbar
+clipboard +insert_expand +path_extra +user_commands
+cmdline_compl +job +perl +vertsplit
+cmdline_hist +jumplist +persistent_undo +virtualedit
+cmdline_info +keymap +postscript +visual
+comments +langmap +printer +visualextra
+conceal +libcall +profile +viminfo
+cryptv +linebreak +python +vreplace
+cscope +lispindent -python3 +wildignore
+cursorbind +listcmds +quickfix +wildmenu
+cursorshape +localmap +reltime +windows
+dialog_con -lua +rightleft +writebackup
+diff +menu +ruby -X11
+digraphs +mksession +scrollbind -xfontset
-dnd +modify_fname +signs -xim
-ebcdic +mouse +smartindent -xsmp
+emacs_tags -mouseshape -sniff -xterm_clipboard
+eval +mouse_dec +startuptime -xterm_save
+ex_extra -mouse_gpm +statusline -xpm
+extra_search -mouse_jsbterm -sun_workshop
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -F/usr/local/Frameworks -DMACOS_X_UNIX -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang -L. -L/Users/jottr/.rbenv/versions/2.3.0/lib -fstack-protector -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -F/usr/local/Cellar/python/2.7.11/Frameworks -framework Python -lruby-static -framework CoreFoundation -lgmp -lobjc -L/Users/jonas/.rbenv/versions/2.3.0/lib
$ rbenv local
2.3.0
ProductName: Mac OS X
ProductVersion: 10.11.3
BuildVersion: 15D21
ITerm2 Build 2.9.20160206
My .vimrc
Ruby syntax is known to be slow. How does it perform with syntax off?
Removing airline did not have an impact on the lag in insert mode, as you can see from the following profile:
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
5 0.000434 <SNR>107_Highlight_Matching_Pair()
1 0.000114 0.000033 <SNR>100_ToggleCursorByMode()
2 0.000097 0.000065 xolox#notes#refresh_syntax()
1 0.000081 0.000055 <SNR>100_GetEscapeCode()
1 0.000076 0.000041 neoyank#_append()
1 0.000035 <SNR>134_add_register()
2 0.000032 xolox#notes#filetype_is_note()
1 0.000018 <SNR>65_SetDefaultCompletionType()
1 0.000017 <SNR>100_TmuxEscape()
1 0.000009 <SNR>100_SupportedTerminal()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
5 0.000434 <SNR>107_Highlight_Matching_Pair()
2 0.000097 0.000065 xolox#notes#refresh_syntax()
1 0.000081 0.000055 <SNR>100_GetEscapeCode()
1 0.000076 0.000041 neoyank#_append()
1 0.000035 <SNR>134_add_register()
1 0.000114 0.000033 <SNR>100_ToggleCursorByMode()
2 0.000032 xolox#notes#filetype_is_note()
1 0.000018 <SNR>65_SetDefaultCompletionType()
1 0.000017 <SNR>100_TmuxEscape()
1 0.000009 <SNR>100_SupportedTerminal()
Setting :syntax off fixed the lag issue. I can't believe that vim still has an issue with the ruby syntax.
I just tried to edit the same file with nvim and the lag issue is present there as well.
Am 2016-03-02 17:26, schrieb jottr:
Removing airline did not have an impact on the lag in insert mode, as
you can see from the following profile:FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
5 0.000434107_Highlight_Matching_Pair()
1 0.000114 0.000033100_ToggleCursorByMode()
2 0.000097 0.000065 xolox#notes#refresh_syntax()
1 0.000081 0.000055100_GetEscapeCode()
1 0.000076 0.000041 neoyank#_append()
1 0.000035134_add_register()
2 0.000032 xolox#notes#filetype_is_note()
1 0.00001865_SetDefaultCompletionType()
1 0.000017100_TmuxEscape()
1 0.000009100_SupportedTerminal() FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
5 0.000434107_Highlight_Matching_Pair()
2 0.000097 0.000065 xolox#notes#refresh_syntax()
1 0.000081 0.000055100_GetEscapeCode()
1 0.000076 0.000041 neoyank#_append()
1 0.000035134_add_register()
1 0.000114 0.000033100_ToggleCursorByMode()
2 0.000032 xolox#notes#filetype_is_note()
1 0.00001865_SetDefaultCompletionType()
1 0.000017100_TmuxEscape()
1 0.000009100_SupportedTerminal()
That looks reasonably fast. However you could disable matchparen plugin,
if it bothers you.
Setting :syntax off fixed the lag issue. I can't believe that vim
still has an issue with the ruby syntax.
I just tried to edit the same file with nvim and the lag issue is
present there as well.
The ruby syntax is known to be slow (because of expansive
regular expressions) and it hasn't changed much IIRC and is
shared between nvim and Vim, so I wouldn't expect a difference there.
I think, I have mentioned the issue for the ruby-syntax repository
in this ticket as well, but as far as I know, there
hasn't been any progress on that.
going to close this soon, if there are no updates here. I consider the ruby syntax to be the culprit, don't think, it is airlines fault.
The culprit was ruby. Issue can be closed. Thx.
Hello
Glad to see I'm not alone. I'm also working on ruby essentially but I see slow down only on very long lines, this is for me an other issue.
With airline Vim is slower in all the other actions (split, closing window split, jump to the other window, motions...). I've run 3 profiles with 2 buffers splited. Every time I just yank a line, insert some text, revert it, jump to the other window than :close it.
At the beginning I though it was gitgutter. So I disable it. But with airline I still have performance issues.
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
2 0.666920 0.000246 gitgutter#process_buffer()
2 0.665241 0.002587 gitgutter#diff#run_diff()
3 0.661911 0.001200 gitgutter#utility#system()
66 0.236637 0.005789 airline#check_mode()
6 0.229510 0.027036 airline#highlighter#highlight()
1 0.218064 0.000203 gitgutter#utility#file_relative_to_repo_root()
1050 0.156695 0.051318 airline#highlighter#exec()
1772 0.118382 0.036893 airline#highlighter#get_highlight()
333 0.106554 0.010153 <SNR>72_exec_separator()
3544 0.068261 <SNR>72_get_syn()
666 0.048577 0.003724 airline#themes#get_highlight()
7350 0.035932 <SNR>72_Get()
7 0.022845 0.002537 9()
9 0.019044 0.000407 airline#extensions#tabline#get()
9 0.018637 0.001391 airline#extensions#tabline#buffers#get()
28 0.015402 0.000340 <SNR>76_get_seperator()
1772 0.013228 <SNR>72_get_array()
35 0.013018 0.000677 <SNR>76_get_transitioned_seperator()
35 0.012341 0.000539 airline#highlighter#add_separator()
2 0.012146 0.000041 <SNR>21_on_window_changed()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
3544 0.068261 <SNR>72_get_syn()
1050 0.156695 0.051318 airline#highlighter#exec()
1772 0.118382 0.036893 airline#highlighter#get_highlight()
7350 0.035932 <SNR>72_Get()
6 0.229510 0.027036 airline#highlighter#highlight()
1772 0.013228 <SNR>72_get_array()
333 0.106554 0.010153 <SNR>72_exec_separator()
54 0.006347 <SNR>50_Highlight_Matching_Pair()
66 0.236637 0.005789 airline#check_mode()
60 0.004775 airline#extensions#whitespace#check()
666 0.048577 0.003724 airline#themes#get_highlight()
60 0.007071 0.003533 airline#extensions#hunks#get_hunks()
39 0.004181 0.003428 airline#extensions#tabline#formatters#default#format()
300 0.003122 airline#util#append()
2 0.665241 0.002587 gitgutter#diff#run_diff()
7 0.022845 0.002537 9()
438 0.002355 airline#util#wrap()
44 0.002066 <SNR>65_update()
42 0.001772 <SNR>76_get_accented_line()
60 0.003538 0.001566 <SNR>62_get_hunks()
Without git gutter
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
104 0.514244 0.009151 airline#check_mode()
13 0.502291 0.064144 airline#highlighter#highlight()
2 0.400568 0.000253 <SNR>18_FileRead()
2 0.399797 0.000347 <SNR>18_repo_rev_parse()
2 0.399450 0.000965 <SNR>18_repo_git_chomp()
2466 0.359586 0.118470 airline#highlighter#exec()
4094 0.268886 0.084217 airline#highlighter#get_highlight()
710 0.222731 0.021535 <SNR>69_exec_separator()
8188 0.154892 <SNR>69_get_syn()
1420 0.102734 0.007764 airline#themes#get_highlight()
26 0.083224 0.009266 9()
17262 0.081905 <SNR>69_Get()
12 0.071159 0.000205 <SNR>21_on_window_changed()
12 0.070908 0.001352 airline#update_statusline()
16 0.069478 0.000661 <SNR>22_invoke_funcrefs()
1 0.060385 0.000984 rails#buffer_setup()
105 0.055001 0.001231 <SNR>73_get_seperator()
129 0.047493 0.002337 <SNR>73_get_transitioned_seperator()
129 0.045156 0.001894 airline#highlighter#add_separator()
17 0.035291 0.000607 airline#extensions#tabline#get()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
8188 0.154892 <SNR>69_get_syn()
2466 0.359586 0.118470 airline#highlighter#exec()
4094 0.268886 0.084217 airline#highlighter#get_highlight()
17262 0.081905 <SNR>69_Get()
13 0.502291 0.064144 airline#highlighter#highlight()
4094 0.029777 <SNR>69_get_array()
392 0.022710 0.021550 <SNR>83_extend_projection()
710 0.222731 0.021535 <SNR>69_exec_separator()
26 0.083224 0.009266 9()
104 0.514244 0.009151 airline#check_mode()
76 0.007909 <SNR>48_Highlight_Matching_Pair()
1420 0.102734 0.007764 airline#themes#get_highlight()
93 0.007098 airline#extensions#whitespace#check()
157 0.006554 <SNR>73_get_accented_line()
48 0.029079 0.006369 <SNR>83_combine_projections()
4 0.028037 0.005647 <SNR>83_readable_projected_with_raw()
13 0.005059 0.004974 <SNR>83_define_navcommand()
75 0.006041 0.004972 airline#extensions#tabline#formatters#default#format()
465 0.004598 airline#util#append()
140 0.004138 0.003674 <SNR>74_get_section()
Without airline.
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
43 0.004727 <SNR>44_Highlight_Matching_Pair()
1 0.002945 0.000377 GetRubyIndent()
6 0.001721 <SNR>57_IsInStringOrComment()
2 0.001654 0.000110 <SNR>57_PrevNonBlankNonString()
1 0.000781 0.000112 <SNR>57_GetMSL()
10 0.000566 0.000132 indent_guides#process_autocmds()
2 0.000438 0.000095 <SNR>20_record()
10 0.000434 0.000085 indent_guides#disable()
1 0.000426 0.000249 <SNR>57_ExtraBrackets()
10 0.000349 0.000275 indent_guides#clear_matches()
2 0.000343 <SNR>20_addtomrufs()
11 0.000250 <SNR>57_Match()
1 0.000108 <SNR>57_IsInString()
10 0.000074 indent_guides#init_matches()
5 0.000074 <SNR>59_resetomnicomplete()
5 0.000053 <SNR>59_RefreshBuffer()
1 0.000046 <SNR>32_Mkdir()
5 0.000037 <SNR>59_BufDatabase()
1 0.000021 <SNR>31_SetDefaultCompletionType()
1 0.000018 <SNR>57_IsInStringOrDocumentation()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
43 0.004727 <SNR>44_Highlight_Matching_Pair()
6 0.001721 <SNR>57_IsInStringOrComment()
1 0.002945 0.000377 GetRubyIndent()
2 0.000343 <SNR>20_addtomrufs()
10 0.000349 0.000275 indent_guides#clear_matches()
11 0.000250 <SNR>57_Match()
1 0.000426 0.000249 <SNR>57_ExtraBrackets()
10 0.000566 0.000132 indent_guides#process_autocmds()
1 0.000781 0.000112 <SNR>57_GetMSL()
2 0.001654 0.000110 <SNR>57_PrevNonBlankNonString()
1 0.000108 <SNR>57_IsInString()
2 0.000438 0.000095 <SNR>20_record()
10 0.000434 0.000085 indent_guides#disable()
10 0.000074 indent_guides#init_matches()
5 0.000074 <SNR>59_resetomnicomplete()
5 0.000053 <SNR>59_RefreshBuffer()
1 0.000046 <SNR>32_Mkdir()
5 0.000037 <SNR>59_BufDatabase()
1 0.000021 <SNR>31_SetDefaultCompletionType()
1 0.000018 <SNR>57_IsInStringOrDocumentation()
My vimrc : https://github.com/benoittgt/dotfiles_osx/blob/master/.vimrc
My vim (I'm using Macvim) :
vim --version [18:26:20]
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 1 2016 10:05:34)
MacOS X (unix) version
Included patches: 1-1202
Compiled by Homebrew
Huge version with MacVim GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm +tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+channel +fullscreen -mzscheme +textobjects
+cindent -gettext +netbeans_intg +title
+clientserver -hangul_input +odbeditor +toolbar
+clipboard +iconv +path_extra +transparency
+cmdline_compl +insert_expand +perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con_gui -lua +rightleft +windows
+diff +menu +ruby +writebackup
+digraphs +mksession +scrollbind -X11
+dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent +xim
+emacs_tags +mouseshape -sniff -xsmp
+eval +mouse_dec +startuptime -xterm_clipboard
+ex_extra -mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop -xpm
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X_UNIX -F/usr/local/Cellar/python/2.7.11/Frameworks -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -L/usr/local/lib -L. -L/usr/local/lib -F/usr/local/Cellar/python/2.7.11/Frameworks -L/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -framework CoreFoundation -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -F/usr/local/Cellar/python/2.7.11/Frameworks -framework Python -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework Ruby
My airline settings :
" Airline
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
set guifont=Droid_Sans_Mono_for_Powerline:h11
let g:airline_powerline_fonts = 1
For the moment I prefer to disable airline even I'm a huge fan of this plugin. :disappointed:
Feel free to reopen the issue if you think it deserve to have a look. I don't think I'm able to do a PR for this one.
Same problem, but I work with Javascript
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
120 0.562115 0.011767 airline#check_mode()
24 0.544631 0.083517 airline#highlighter#highlight()
2676 0.391794 0.139648 airline#highlighter#exec()
4188 0.320419 0.114960 airline#highlighter#get_highlight()
636 0.193094 0.022404 <SNR>66_exec_separator()
12 0.186245 0.000673 <SNR>38_on_window_changed()
12 0.185530 0.001659 airline#update_statusline()
48 0.183648 0.002133 <SNR>39_invoke_funcrefs()
8376 0.182051 <SNR>66_get_syn()
48 0.151237 0.026264 273()
1272 0.106630 0.008335 airline#themes#get_highlight()
120 0.074709 0.002312 <SNR>70_get_seperator()
62 0.072642 0.001435 airline#extensions#branch#get_head()
62 0.071206 0.002562 airline#extensions#branch#head()
120 0.062004 0.007738 bufferline#get_echo_string()
156 0.060902 0.003380 <SNR>70_get_transitioned_seperator()
156 0.057523 0.002704 airline#highlighter#add_separator()
120 0.054266 <SNR>43_generate_names()
10920 0.052304 <SNR>66_Get()
62 0.049142 0.025221 <SNR>63_update_branch()
Here are my vimrc and profile.log files (changed extension so that github would allow me to upload them).
The problem appears randomly after I open a few (about 4) buffers with javascript files. I keep them together on the screen in the splits, and switching between them starts taking 1-2 seconds at certain point. I enabled profile as soon as it happened, and only kept it running while I was repeating the slow switching from one split to another and back.
and if you disable syntax highlighting, how does it work? Try running :syntime report
After reproducing the issue once again, I ran syntime on and switched splits a little bit. Here's my syntime report:
TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
0.020672 3547 922 0.000416 0.000006 javaScriptNumber -\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>
0.012832 2855 644 0.001998 0.000004 javaScriptBraces [{}\[\]]
0.012139 4189 1564 0.001414 0.000003 javaScriptParens [()]
0.005011 1520 1520 0.000074 0.000003 javaScriptStringD "\|$
0.002931 2718 186 0.000027 0.000001 javaScriptLineComment \/\/.*
0.002751 1382 0 0.000023 0.000002 javaScriptRegexpString /[gim]\{0,2\}\s*[;.,)\]}]
0.002367 3914 1474 0.000031 0.000000 javaScriptRegexpString /[^/*]
0.002355 2625 0 0.000022 0.000001 javaScriptCommentSkip ^[ \t]*\*\($\|[ \t]\+\)
0.002152 1382 0 0.000027 0.000002 javaScriptRegexpString /[gim]\{0,2\}\s*$
0.000968 2625 138 0.000018 0.000000 javaScriptComment /\*
0.000896 4283 1889 0.000018 0.000000 javaScriptStringD "
0.000796 2625 0 0.000016 0.000000 javaScriptSpecialCharacter '\\.'
0.000777 2625 0 0.000023 0.000000 javaScriptStringS '
0.000725 2625 0 0.000004 0.000000 javaScriptSpecial \\\d\d\d\|\\.
0.000393 1520 0 0.000001 0.000000 javaScriptStringD \\\\\|\\"
0.000049 138 138 0.000002 0.000000 javaScriptComment \*/
0.067814 40573
that doesn't look to bad. I don't know, why it is so slow for you
@chrisbra I tried profiling it once again. Here's the functions sorted on self time, after just a couple of switches between spils:
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
5776 0.130108 <SNR>62_get_syn()
1848 0.266224 0.093695 airline#highlighter#exec()
2888 0.226636 0.079235 airline#highlighter#get_highlight()
16 0.373112 0.061241 airline#highlighter#highlight()
7504 0.037401 <SNR>62_Get()
32 0.132611 0.024283 273()
440 0.147943 0.018639 <SNR>62_exec_separator()
2888 0.017293 <SNR>62_get_array()
26 0.022876 0.011689 <SNR>60_update_branch()
16 0.010692 <SNR>43_addtomrufs()
136 0.008900 <SNR>66_get_accented_line()
184 0.009586 0.008667 <SNR>67_get_section()
26 0.008758 0.008406 <SNR>60_update_untracked()
1 0.007952 0.007884 ctrlp#utils#writecache()
880 0.079426 0.006646 airline#themes#get_highlight()
136 0.013280 0.005537 <SNR>67_add_section()
168 0.018649 0.004988 <SNR>66_section_is_empty()
26 0.005297 0.004957 <SNR>41_repo_head_ref()
44 0.380232 0.003675 airline#check_mode()
40 0.016668 0.003388 <SNR>67_build_sections()
Why does get_syn() get called almost 6 thousand times, and Get() 7 and a half thousand? Is that normal?
I still suffer from this issue, so I decided to dig deeper. Here's what I've found in the profile:
FUNCTION airline#highlighter#highlight()
Called 213 times
Total time: 7.351742
Self time: 1.100684
count total (s) self (s)
213 0.000683 let bufnr = a:0 ? a:1 : ''
213 0.000812 let p = g:airline#themes#{g:airline_theme}#palette
" draw the base mode, followed by any overrides
213 0.002293 let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
213 0.000608 let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
499 0.001014 for mode in mapped
286 0.001785 if exists('g:airline#themes#{g:airline_theme}#palette[mode]')
213 0.000754 let dict = g:airline#themes#{g:airline_theme}#palette[mode]
7839 0.023740 for kvp in items(dict)
7626 0.022994 let mode_colors = kvp[1]
7626 0.017273 let name = kvp[0]
7626 0.022534 if name is# 'airline_c' && !empty(bufnr) && suffix is# '_inactive'
106 0.000192 let name = 'airline_c'.bufnr
106 0.000059 endif
7626 1.194387 0.056652 call airline#highlighter#exec(name.suffix, mode_colors)
22878 0.055221 for accent in keys(s:accents)
15252 0.046621 if !has_key(p.accents, accent)
continue
endif
15252 0.058625 let colors = copy(mode_colors)
15252 0.048475 if p.accents[accent][0] != ''
7626 0.021135 let colors[0] = p.accents[accent][0]
7626 0.005130 endif
15252 0.030317 if p.accents[accent][2] != ''
7626 0.016027 let colors[2] = p.accents[accent][2]
7626 0.004594 endif
15252 0.023039 if len(colors) >= 5
15252 0.052923 let colors[4] = get(p.accents[accent], 4, '')
15252 0.011282 else
call add(colors, get(p.accents[accent], 4, ''))
endif
15252 3.160764 0.128285 call airline#highlighter#exec(name.suffix.'_'.accent, colors)
15252 0.017275 endfor
7626 0.006830 endfor
" TODO: optimize this
6181 0.018014 for sep in items(s:separators)
5968 2.152311 0.071467 call <sid>exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix)
5968 0.006827 endfor
213 0.000173 endif
286 0.000183 endfor
I'm not 100% sure what's happening here, just going from the names of the variables and functions. But it seems that the syntax highlighter is doing MUCH more work than required. Will dig it further.
@chrisbra please re-open this issue.
well, the statusline is updated often. However, I suspect if one uses a theme, that does not switch colors a lot, one might get better performance. It's known that executing :hi ... calls is slow. However I don't have an idea how to make it much faster.
Is there any other information or configuration I can provide to help?
what theme are you using? Can you try one, that doesn't switch colors that often, e.g. papercolor?
Are you talking about vim colorscheme? Molokai. Or does airline have themes too? Here's all my Airline-related part of the vimrc:
let g:airline_detect_spell=0
let g:airline_powerline_fonts = 1
let g:airline_skip_empty_sections = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#wordcount#enabled = 0
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#branch#displayed_head_limit = 10
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" airline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
Another clarification: all I did to reproduce the issue was opening a few splits with long Javascript files and jump between them. Every jump has a noticeable lag.
I didn't enter or exit edit and visual mode to reproduce this - these actions actually aren't laggy.
Switched to papercolor colorscheme, issue isn't reproducing yet. However, after opening Vim it takes time for the lag to appear, so I'm not yet sure if it's related to colorscheme or not.
I think those long running commands are actually done by changing color definitions using :hi airline_a which depends on the mode. I created a minimal dark scheme, which shouldn't change colors at all, so this should not call those expensive :hi colors since it should detect that the color is the same (hopefully that isn't as expansive as well). So you might try with this dark_minimal scheme. Simply copy it under ~/.vim/bundle/vim-airline-themes/autoload/airline/themes/ and switch to it using :AirlineTheme dark_minimal
if that is stilly laggy, it would be interesting, what parts of airline#highlighter#exec are that expansive.
I don't think that it has anything to do with colorscheme, in the end.
One sure way to reproduce the lag is edit the file and then jump to another split. Even adding a single space will cause Vim to lag when I jump to another buffer; when I jump between them a couple of time afterwards, there's no lag.
Here's how my profile looks when I do this a few times:
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
74430 1.991369 <SNR>65_get_syn()
25185 4.500643 1.595458 airline#highlighter#exec()
37215 3.397535 1.154428 airline#highlighter#get_highlight()
99 6.659685 1.010520 airline#highlighter#highlight()
107856 0.651820 <SNR>65_Get()
479 0.535950 0.299426 <SNR>63_update_branch()
479 0.282126 0.265160 <SNR>63_update_untracked()
37215 0.251739 <SNR>65_get_array()
5745 2.057082 0.246091 <SNR>65_exec_separator()
29 0.414933 0.205589 gitgutter#diff#run_diff()
479 0.109735 0.102297 <SNR>41_repo_head_ref()
108 0.567866 0.097719 273()
29 0.090861 0.088156 gitgutter#async#execute()
11490 1.148479 0.085409 airline#themes#get_highlight()
56 0.071529 <SNR>43_addtomrufs()
218 0.065311 <SNR>50_Highlight_Matching_Pair()
441 6.745287 0.049402 airline#check_mode()
459 0.036626 <SNR>69_get_accented_line()
621 0.038332 0.034857 <SNR>70_get_section()
958 0.030686 <SNR>41_repo()
Here are all the places where highlighter gets called from:
FUNCTION <SNR>65_exec_separator()
Called 5745 times
Total time: 2.057082
Self time: 0.246091
count total (s) self (s)
5745 0.010064 if pumvisible()
return
endif
5745 0.658690 0.035748 let l:from = airline#themes#get_highlight(a:from.a:suffix)
5745 0.560180 0.034643 let l:to = airline#themes#get_highlight(a:to.a:suffix)
5745 0.019705 let group = a:from.'_to_'.a:to.a:suffix
5745 0.006124 if a:inverse
1410 0.008102 let colors = [ l:from[1], l:to[1], l:from[3], l:to[3] ]
1410 0.001291 else
4335 0.021562 let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ]
4335 0.003011 endif
5745 0.024114 let a:dict[group] = colors
5745 0.702037 0.039525 call airline#highlighter#exec(group, colors)
FUNCTION airline#highlighter#highlight_modified_inactive()
Called 99 times
Total time: 0.036199
Self time: 0.005018
count total (s) self (s)
99 0.000609 if getbufvar(a:bufnr, '&modified')
87 0.001230 let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c') ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : []
87 0.000087 else
12 0.000196 let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive.airline_c') ? g:airline#themes#{g:airline_theme}#palette.inactive.airline_c : []
12 0.000010 endif
99 0.000211 if !empty(colors)
99 0.032515 0.001334 call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors)
99 0.000082 endif
FUNCTION airline#highlighter#highlight()
Called 99 times
Total time: 6.659685
Self time: 1.010520
count total (s) self (s)
99 0.000330 let bufnr = a:0 ? a:1 : ''
99 0.000567 let p = g:airline#themes#{g:airline_theme}#palette
" draw the base mode, followed by any overrides
99 0.001815 let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
99 0.000424 let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
285 0.000642 for mode in mapped
186 0.001529 if exists('g:airline#themes#{g:airline_theme}#palette[mode]')
186 0.000814 let dict = g:airline#themes#{g:airline_theme}#palette[mode]
6633 0.021056 for kvp in items(dict)
6447 0.021733 let mode_colors = kvp[1]
6447 0.015030 let name = kvp[0]
6447 0.020626 if name is# 'airline_c' && !empty(bufnr) && suffix is# '_inactive'
52 0.000085 let name = 'airline_c'.bufnr
52 0.000028 endif
6447 1.138545 0.052130 call airline#highlighter#exec(name.suffix, mode_colors)
19341 0.052991 for accent in keys(s:accents)
12894 0.043483 if !has_key(p.accents, accent)
continue
endif
12894 0.054924 let colors = copy(mode_colors)
12894 0.045856 if p.accents[accent][0] != ''
6447 0.020530 let colors[0] = p.accents[accent][0]
6447 0.004884 endif
12894 0.028224 if p.accents[accent][2] != ''
6447 0.015930 let colors[2] = p.accents[accent][2]
6447 0.004541 endif
12894 0.022004 if len(colors) >= 5
12894 0.046616 let colors[4] = get(p.accents[accent], 4, '')
12894 0.010674 else
call add(colors, get(p.accents[accent], 4, ''))
endif
12894 2.842415 0.121881 call airline#highlighter#exec(name.suffix.'_'.accent, colors)
12894 0.017277 endfor
6447 0.006864 endfor
" TODO: optimize this
5580 0.015198 for sep in items(s:separators)
5394 1.907921 0.065705 call <sid>exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix)
5394 0.006396 endfor
186 0.000147 endif
186 0.000138 endfor
And here the highlighter itself:
FUNCTION airline#highlighter#exec()
Called 25185 times
Total time: 4.500643
Self time: 1.595458
count total (s) self (s)
25185 0.045101 if pumvisible()
return
endif
25185 0.043678 let colors = a:colors
25185 0.032383 if s:is_win32term
let colors[2] = s:gui2cui(get(colors, 0, ''), get(colors, 2, ''))
let colors[3] = s:gui2cui(get(colors, 1, ''), get(colors, 3, ''))
endif
25185 2.406407 0.153042 let old_hi = airline#highlighter#get_highlight(a:group)
25185 0.049546 if len(colors) == 4
5745 0.013468 call add(colors, '')
5745 0.003824 endif
25185 0.040652 if old_hi != colors
15408 1.121586 0.469766 let cmd = printf('hi %s %s %s %s %s %s %s %s', a:group, s:Get(colors, 0, 'guifg=', ''), s:Get(colors, 1, 'guibg=', ''), s:Get(colors, 2, 'ctermfg=', ''), s:Get(colors, 3, 'ctermbg=', ''), s:Get(colors, 4, 'gui=', ''), s:Get(colors, 4, 'cterm=', ''), s:Get(colors, 4, 'term=', ''))
15408 0.289560 exe cmd
15408 0.015742 endif
All of it was just jumping around two javascript files after adding or removing a space at the end of the random line.
(Just to clarify, above logs are with paperclip, haven't tried your scheme yet).
And here's get_highlight from the same log as above:
FUNCTION airline#highlighter#get_highlight()
Called 37215 times
Total time: 3.397535
Self time: 1.154428
count total (s) self (s)
37215 1.316940 0.211526 let fg = s:get_syn(a:group, 'fg')
37215 1.095553 0.209598 let bg = s:get_syn(a:group, 'bg')
37215 0.407606 let reverse = g:airline_gui_mode ==# 'gui' ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui') : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm')|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term')
37215 0.520943 0.269204 return reverse ? s:get_array(bg, fg, a:000) : s:get_array(fg, bg, a:000)
so it is not actually the real :hi command, but the get_highlight() function and possibly the s:Get command (I can't believe that a simple printf() is that expansive).
And here's get_syn():
FUNCTION <SNR>65_get_syn()
Called 74430 times
Total time: 1.991369
Self time: 1.991369
count total (s) self (s)
74430 0.191144 if !exists("g:airline_gui_mode")
let g:airline_gui_mode = airline#init#gui_mode()
endif
74430 0.734863 let color = synIDattr(synIDtrans(hlID(a:group)), a:what, g:airline_gui_mode)
74430 0.156541 if empty(color) || color == -1
5276 0.044543 let color = synIDattr(synIDtrans(hlID('Normal')), a:what, g:airline_gui_mode)
5276 0.003950 endif
74430 0.123801 if empty(color) || color == -1
let color = 'NONE'
endif
74430 0.077115 return color
thanks. So it is actually moving from one window to the other one, that shows that slowness? I have to think if we can cache something there.
@chrisbra only after I change the content of the window and don't write it to file. At least, it really raises the probability of the lag.
so you have 2 split windows, one is modified and when switching windows you see the slowness?
Not just "modified" - modified right now, before switching to another window. If I just switch between windows that have been modified (and not saved since) some time ago, I experience lag with a much lower probability. Unfortunately, it's not a strict reproduction scenario - sometimes it's laggy to switch between files that just have been opened, and sometimes it's pretty smooth.
Data structures in for kvp in items(dict) and for accent in keys(s:accents) (in the airline#highlighter#highlight() method), are they modified when I edit or save the file? May be it's related to the fact that airline adds "[+]" to the filename and changes it's color when it's modified and not saved?
can you please share a sample javascript file, that shows the behaviour?
Not sure if this helps but a similar discussion on SO
Editing any files with no airline reduces the scrolling lag by a lot. It is noticeable speed up.
I had just a silly idea. If I am going to skip a couple of update events for airline, it should be faster (and perhaps less accurate). So would anybody test this patch and report back, whether it works better:
diff --git a/autoload/airline.vim b/autoload/airline.vim
index d54fe03..864fb44 100644
--- a/autoload/airline.vim
+++ b/autoload/airline.vim
@@ -147,6 +147,9 @@ function! airline#check_mode(winnr)
let s:airline_run = 0
endif
let s:airline_run += 1
+ if s:airline_run % 2 == 0
+ return ''
+ endif
let context = s:contexts[a:winnr]
Note, this is a silly hack.
I was profiling to see why vim scrolling is laggy in my js files (2k+ lines, hundreds of lines of comments). I see a lot of time consumed by airline extension functions. When I remove airline, I have significant improvement in the scrolling speed.
which extension function?
Note, I just commited some changes, that should make airline slightly faster
@chrisbra This is a part of my profiling report:
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
5720 0.593824 0.333219 airline#extensions#hunks#get_hunks()
11440 0.503767 0.287176 airline#extensions#ale#get()
5720 0.402882 0.342916 airline#extensions#whitespace#check()
5720 0.371570 airline#check_mode()
5720 0.286056 0.024088 airline#extensions#ale#get_warning()
5720 0.263583 0.021784 airline#extensions#ale#get_error()
5720 0.260605 0.104320 <SNR>129_get_hunks()
34320 0.249373 airline#util#append()
11440 0.216591 0.063260 ale#statusline#Count()
40040 0.160520 airline#util#wrap()
5720 0.156285 0.042596 <SNR>129_get_hunks_gitgutter()
11440 0.153331 <SNR>162_GetCounts()
11440 0.124425 airline#util#shorten()
850 0.104799 0.073846 <SNR>157_OnCursorMovedNormalMode()
5720 0.095354 0.030895 airline#parts#mode()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
5720 0.371570 airline#check_mode()
5720 0.402882 0.342916 airline#extensions#whitespace#check()
5720 0.593824 0.333219 airline#extensions#hunks#get_hunks()
11440 0.503767 0.287176 airline#extensions#ale#get()
34320 0.249373 airline#util#append()
5720 1.966285 0.187569 bufferline#get_echo_string()
40040 0.160520 airline#util#wrap()
11440 0.153331 <SNR>162_GetCounts()
11440 0.124425 airline#util#shorten()
5720 0.260605 0.104320 <SNR>129_get_hunks()
850 0.104799 0.073846 <SNR>157_OnCursorMovedNormalMode()
11440 0.216591 0.063260 ale#statusline#Count()
5720 0.058371 0.057473 airline#extensions#tagbar#currenttag()
5720 0.053228 airline#statusline()
5720 0.044499 gitgutter#utility#getbufvar()
5720 0.156285 0.042596 <SNR>129_get_hunks_gitgutter()
what airline version did you check?
I think, its https://github.com/vim-airline/vim-airline/commit/583ae3d5f96f91abb37467028eed1a39302a819f. I Just pulled the recent changes. Will share the newer profile in a few min
I see a significant improvement in the newest version.
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
2716 1.946900 <SNR>107_Highlight_Matching_Pair()
1268 0.261689 0.011793 airline#extensions#tabline#get_buffer_name()
2716 0.259638 0.057609 ale#cursor#EchoCursorWarningWithDelay()
2716 0.251844 0.149669 <SNR>154_OnCursorMovedNormalMode()
1268 0.247311 0.016266 airline#extensions#tabline#formatters#webdevicons#format()
3115 0.218697 0.053726 ale#ShouldDoNothing()
1719 0.195073 0.108332 airline#extensions#hunks#get_hunks()
634 0.157980 0.018784 airline#extensions#tabline#title()
1268 0.148230 WebDevIconsGetFileTypeSymbol()
634 0.142933 0.039742 airline#extensions#tabline#get()
1719 0.131933 airline#check_mode()
1719 0.125475 0.106821 airline#extensions#whitespace#check()
6230 0.114649 ale#Var()
2716 0.109627 <SNR>133_wordcount_update()
634 0.103191 0.011213 airline#extensions#tabline#tabs#get()
2716 0.102175 0.010255 <SNR>154_AllowedToCompleteInCurrentBuffer()
634 0.091978 airline#extensions#tabline#tabs#map_keys()
2716 0.091920 0.082424 <SNR>154_AllowedToCompleteInBuffer()
1719 0.086741 0.033200 <SNR>127_get_hunks()
1268 0.082815 0.067127 airline#extensions#tabline#formatters#default#format()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
2716 1.946900 <SNR>107_Highlight_Matching_Pair()
2716 0.251844 0.149669 <SNR>154_OnCursorMovedNormalMode()
1268 0.148230 WebDevIconsGetFileTypeSymbol()
1719 0.131933 airline#check_mode()
6230 0.114649 ale#Var()
2716 0.109627 <SNR>133_wordcount_update()
1719 0.195073 0.108332 airline#extensions#hunks#get_hunks()
1719 0.125475 0.106821 airline#extensions#whitespace#check()
634 0.091978 airline#extensions#tabline#tabs#map_keys()
2716 0.091920 0.082424 <SNR>154_AllowedToCompleteInBuffer()
10314 0.078812 airline#util#append()
3438 0.081408 0.075401 airline#extensions#ale#get()
1268 0.082815 0.067127 airline#extensions#tabline#formatters#default#format()
2716 0.259638 0.057609 ale#cursor#EchoCursorWarningWithDelay()
3115 0.218697 0.053726 ale#ShouldDoNothing()
12033 0.047653 airline#util#wrap()
3438 0.040827 airline#util#shorten()
634 0.142933 0.039742 airline#extensions#tabline#get()
1719 0.086741 0.033200 <SNR>127_get_hunks()
3115 0.027818 ale#util#InSandbox()
My scrolling speed improved noticibaly. Thank you.
BTW, I also looked into other plugins in my javascript environment, also deactivated a few other plugins as well. But, adding set ttyfast, set lazyredraw to my .vimrc greatly improved scrolling experience in my stock gnome-terminal. Would recommend other users to look into these options.
looks like gitgutter could need some caching. I don't use it, so can't tell for sure.
okay, did some more small improvements. However, you could try using a different hunk plugin. From your first report it looks like gitgutter does not cache the values and therefore does a lot of work more often. Also I am a bit at loss why those airline#util.. functions appear there. I mean they are called a lot, but they are really simple. Perhaps, if we find a way to cache winwidth(0) correctly they could be improved as well. lastly, I am wondering why the wordcount() is so slow. Just to be sure, you have a Vim with the builtin function wordcount(), right?
may be @airblade can comment for the git gutter problem
@chrisbra Please could you tell me where the gitgutter problem is? Looking at the profile four comments above, I can't see any gitgutter calls.
Update: I saw you mentioned GitGutterGetHunkSummary() in 174b7e196 as a culprit for slowness, but all it does is return a buffer variable.
From that report there are 5720 calls to <SNR>129_get_hunks_gitgutter() and I think this calls internally GitGutterGetHunkSummary() which I believe is a function from your plugin.
I had a quick look into your plugin, but it wasn't quite obvious, if you already use caching. So in case you don't do it, you might want to think about it ;)
However, since that function does not appear in the later report, it might be okay to simply ignore it for now until some other users complain ;)
Thanks for the clarification.
I'm not sure if you saw the update I made to my comment as GitHub doesn't re-email a comment when it is changed, but GitGutterGetHunkSummary() simply returns a buffer variable – the hunk stats are calculated and stored whenever a diff is run, so reading the stats is cheap.
oh thanks. Let's just ignore the issue then.
i did some small changes, that should speed up highlighting. Try setting :let g:airline_highlighting_cache=1 and see if this works better.
Seems to work. Thanks.
closing then for now.
Hi,
Start of gvim under windows 10 takes 2-3 seconds .... I hope this infos can help to optimize airline.
With Airline and Airline themes
### FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
14 **1.729241** 0.001966 airline#extensions#tagbar#currenttag()
7 1.724842 0.000513 tagbar#currenttag()
7 1.724293 0.000570 <SNR>106_Init()
2 1.621424 0.010315 <SNR>106_ExecuteCtags()
Without Airline and Airline themes
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
1 0.031481 0.003112 plug#end()
2 0.028372 0.001564 XPTemplateInit()
1 0.023820 0.003208 <SNR>73_XPTinitMapping()
8 0.022355 0.009191 xpt#once#SetAndGetLoaded()
325 0.013164 <SNR>67_Norm()
1 0.006505 0.000011 <SNR>36_savetofile()
1 0.006494 0.006446 ctrlp#utils#writecache()
1 0.005127 xpt#util#getCmdOutput()
1 0.002486 0.000407 <SNR>36_mergelists()
22 0.001784 0.000701 plug#()
1 0.001768 0.001177 ctrlp#mrufiles#cachefile()
_vimrc and version
```
" Maintainer: NiVa
" Last change: 2018 February
"
profile start $tmp/profile.log
profile func *
set nocompatible
let s:fast_start=0
" Airline settings {{{
let g:airline_theme = 'cool'
" let g:airline_extensions = [] slower if uncommented
let g:airline_powerline_fonts = 1
let g:airline_highlighting_cache = 1 " slower if 0 beside of written in helps..
set laststatus=2
"}}}
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-1453
Huge version with GUI. Features included (+) or not (-):
+acl +clipboard +digraphs +folding +linebreak -mzscheme +python3/dyn +tag_binary +user_commands -xim
+arabic +cmdline_compl +directx -footer +lispindent -netbeans_intg +quickfix +tag_old_static +vertsplit -xpm_w32
+autocmd +cmdline_hist -dnd +gettext/dyn +listcmds +num64 +reltime -tag_any_white +virtualedit -xterm_save
+autoservername +cmdline_info -ebcdic -hangul_input +localmap +ole +rightleft -tcl +visual
+balloon_eval +comments +emacs_tags +iconv/dyn +lua/dyn +packages +ruby/dyn -termguicolors +visualextra
-balloon_eval_term +conceal +eval +insert_expand +menu +path_extra +scrollbind +terminal +viminfo
+browse +cryptv +ex_extra +job +mksession -perl +signs -tgetent +vreplace
++builtin_terms -cscope +extra_search +jumplist +modify_fname +persistent_undo +smartindent -termresponse +wildignore
+byte_offset +cursorbind +farsi +keymap +mouse -postscript +startuptime +textobjects +wildmenu
+channel +cursorshape +file_in_path +lambda +mouseshape +printer +statusline +timers +windows
+cindent +dialog_con_gui +find_in_path +langmap +multi_byte +profile -sun_workshop +title +writebackup
+clientserver +diff +float +libcall +multi_lang +python/dyn +syntax +toolbar -xfontset
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME_vimrc"
2nd user vimrc file: "$HOME\vimfiles\vimrc"
3rd user vimrc file: "$VIM_vimrc"
user exrc file: "$HOME_exrc"
Thank you in advance
Niva
Most helpful comment
i did some small changes, that should speed up highlighting. Try setting
:let g:airline_highlighting_cache=1and see if this works better.