Dominique Pelle wrote:
> patrick hemmer wrote:
>
> > Whenever I have relative line number on (relativenumber), and
> > syntax highlighting enabled (syntax on), moving the cursor is
> > painfully slow. Not only moving between lines, but just moving
> > the cursor left/right on the same line.
> >
> > I've tried removing my local .vim & .vimrc files as well as the
> > ones in /etc to have a completely default config. As soon as
> > I `syntax on` and `set rnu`, it starts exhibiting the issue.
> >
> > It doesn't seem to do this on all files though, just most. As a
> > reliable way to duplicate the issue, I can copy the http://yaml.org
> > web page content into a .yaml file, and edit that.
> > But I get it in multiple languages, perl, yaml, ruby, & other.
> >
> > Version 7.4 with patches 1-193 (though I've had this behavior for
> > years with older versions).
>
> I can reproduce the slowness using the yaml file copied
> from http://yaml.org
>
> Here are some timings with and without relativenumber
> when moving 50 times horizontally with l and h:
>
> $ time vim -u NONE foo.yaml \
> -c 'set relativenumber' \
> -c 'syntax on' +10 \
> -c 'call feedkeys("llllllllllhhhhhhhhhhllllllllllhhhhhhhhhhllllllllll:q\<CR>")'
> real 0m4.677s
> user 0m1.447s
> sys 0m3.226s
> --> slow!
>
> $ time vim -u NONE foo.yaml \
> -c 'set norelativenumber' \
> -c 'syntax on' +10 \
> -c 'call feedkeys("llllllllllhhhhhhhhhhllllllllllhhhhhhhhhhllllllllll:q\<CR>")'
> real 0m0.166s
> user 0m0.086s
> sys 0m0.077s
> --> fast
>
> If I use ":syntime on" and ":syntime report", I see this:
>
> With relativenumber:
>
> TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
> 3.706423 7752 7395 0.002521 0.000478 yamlPlainScalar
[...]
>
> Without relative number:
>
> TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
> 0.071678 152 145 0.001796 0.000472 yamlPlainScalar
[...]
> So somehow regexp are being checked far more often
> when relativenumber is on, which does not seem right
> considering that the command mostly moves horizontally.
>
> Using callgrind, I see that:
> * with 'norelativenumber', update_screen() was called only once
> * with 'relativenumber', update_screen() was called 51 times
>
> Notice that the command I used was moving:
> - 50 times horizontally with h and l
> - 1 time vertically using +10
>
> This means that with relativenumber, update_screen() gets
> called each time we move horizontally with h or l which does
> not seem needed at first sight.
>
> The code that seems responsible for the spurious redraw is:
> move.c:1190 (commenting that line as a experiment makes it fast)
> so the logic to decide whether to redraw is wrong but I can't see
> how to fix it:
>
> 1175 /* Redraw when w_row changes and 'relativenumber' is set */
> 1176 if (((curwin->w_valid & VALID_WROW) == 0 && (curwin->w_p_rnu
> 1177 #ifdef FEAT_SYN_HL
> 1178 /* or when w_row changes and 'cursorline' is set. */
> 1179 || curwin->w_p_cul
> 1180
No comments:
Post a Comment