Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 282 by [email protected]: Ruby syntax highlighting w/ either
cursorline or relativenumber causes lag from high CPU usage
https://code.google.com/p/vim/issues/detail?id=282
With ruby syntax highlighting on, turning on cursorline or relativenumber
settings causes lag due to high CPU usage when moving the cursor up and
down. The conditions below exaggerbate the problem to help make it obvious
and reproducible, but the same problem exists at lesser scale with smaller
terminal sizes. This is a significant problem though, because when CPUs are
otherwise bogged down (eg. when pair programming with someone via screen
share on Google Hangouts), moving the cursor in a ruby file can be
ridiculously slow.
What steps will reproduce the problem?
1. Temporarily rename ~/.vim/ and ~/.vimrc to ensure nothing but vanilla vim
2. Resize the terminal window so that ~100 lines are visible (normal for
large monitors)
3. Open a ruby file with non-trivial syntax:
https://raw.githubusercontent.com/rails/rails/f43f56e/activerecord/lib/active_record/associations.rb
4. :syntax on
5. :set relativenumber
6. Hold down j or <down> for 1-2 seconds. (Ensure the system's keyboard
repeat rate is not slow, ideally maxed)
7. Notice that CPU usage for the vim process is at 100%, accompanied by
choppy redrawing and lag. Upon releasing the j/<down> key, buffered
keypresses continue to move the cursor down.
What is the expected behavior?
1. With the same file open and under the same conditions, :set syntax=java
2. Notice there is no longer excessive CPU usage or any lag when moving the
cursor up and down. The cursor stops moving immediately when the key is
released.
---
I understand that ruby's syntax is complex and nontrivial to parse. If
there's no clear way to reduce CPU usage for parsing ruby syntax for syntax
highlighting, are there other ways you can think of to prevent the syntax
highlighting from having to be recalculated when the screen is redrawn for
relativenumber and cursorline? Can we profile and find where the problem
lies?
---
I can reproduce this in Vim 7.4 on both Ubuntu and OSX:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 12 2014 20:26:50)
MacOS X (unix) version
Included patches: 1-488
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
+cindent -gettext -mzscheme +textobjects
-clientserver -hangul_input +netbeans_intg +title
+clipboard +iconv +path_extra -toolbar
+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 -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"
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.10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang -L. -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
-framework Python -lruby.2.0.0 -lobjc
AND
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 15 2013 11:04:13)
Included patches: 1-5
Modified by [email protected]
Compiled by buildd@
Huge version without GUI. Features included (+) or not (-):
+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
+cindent +gettext -mzscheme +textobjects
-clientserver -hangul_input +netbeans_intg +title
-clipboard +iconv +path_extra -toolbar
+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 +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
+farsi +mouse_netterm +syntax
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/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
-Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
-I/usr/include/tcl8.5 -D_REENTRANT=1 -D_THREAD_SAFE=1
-D_LARGEFILE64_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic
-Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro
-Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr
-lgpm -ldl -L/usr/lib -llua5.1 -Wl,-E -fstack-protector -L/usr/local/lib
-L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt
-L/usr/lib/python2.7/config-x86_64-linux-gnu
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.