On Thursday, March 27, 2014 7:13:06 AM UTC-4, Bram Moolenaar wrote:
> 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 #endif
> 
> > 1181         ))
> 
> > 1182 #ifdef FEAT_SYN_HL
> 
> > 1183         /* or when w_virtcol changes and 'cursorcolumn' is set */
> 
> > 1184         || (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0)
> 
> > 1185 #endif
> 
> > 1186         )
> 
> > 1187 # ifdef FEAT_INS_EXPAND
> 
> > 1188             if (!pum_visible())
> 
> > 1189 # endif
> 
> > 1190                 redraw_later(SOME_VALID);
> 
> > 
> 
> > I'm using Vim-7.4.218 on Linux x86_64 in the xfce4-terminal.
> 
> 
> 
> Thanks for digging this up.  When 'relativenumber' is set a redraw is
> 
> only neede when the buffer line number changes.  But the condition is
> 
> for the screen line number to change.  It should use the VALID_CROW
> 
> mask.  Same for when 'cursorline' is set.
> 
> 
> 
> I'll make a patch, please make sure it still updates properly when
> 
> needed after including it.
> 
> 
> 
> -- 
> 
> At some point in the project somebody will start whining about the need to
> 
> determine the project "requirements".  This involves interviewing people who
> 
> don't know what they want but, curiously, know exactly when they need it.
> 
>                               (Scott Adams - The Dilbert principle)
> 
> 
> 
>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
> 
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> 
> \\\  an exciting new programming language -- http://www.Zimbu.org        ///
> 
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///


Pardon my ignorance here, but when using relativenumber, the idea is that when 
the cursor screen line number changes, it should redraw the whole window right? 
Would it not be more efficient to only redraw the line numbers on the left hand 
side?
If I've got a terminal with very large dimensions, redrawing the whole thing is 
really expensive, but redrawing a few hundred characters on the left hand side 
would be a lot faster.

-- 
-- 
You received this message from the "vim_use" 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_use" 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.

Reply via email to