Profile Cursor move (very slow)

44 views
Skip to first unread message

N i c o l a s I I T h e B l o o d y

unread,
Dec 9, 2022, 11:36:18 AM12/9/22
to vim_dev
Hi,

Vertical moving cursor with arrow keys on such a file  like https://github.com/preservim/tagbar/blob/master/autoload/tagbar.vim is very very slow.

How can I measure it with profiling feature ?
Thank you
N i c o l a s

Enan Ajmain

unread,
Dec 9, 2022, 2:32:09 PM12/9/22
to N i c o l a s I I T h e B l o o d y, vim...@googlegroups.com
On Fri, 9 Dec 2022 08:36:18 -0800 (PST)
N i c o l a s I I T h e B l o o d y <niva...@gmail.com> wrote:
> Hi,
>
> Vertical moving cursor with arrow keys on such a file
> like https://github.com/preservim/tagbar/blob/master/autoload/tagbar.vim is
> very very slow.
>
> How can I measure it with profiling feature ?

Read ':h profiling'.


--
Enan
3nan....@gmail.com
https://git.sr.ht/~enan/
https://www.github.com/3N4N

N i c o l a s I I T h e B l o o d y

unread,
Dec 9, 2022, 3:12:07 PM12/9/22
to vim_dev
Thank you Enan, I saw thé profile help but don't happen to find particular sample for Cursor move. 😊 
N i c o l a s

Enan Ajmain

unread,
Dec 10, 2022, 2:02:36 AM12/10/22
to niva...@gmail.com, vim...@googlegroups.com
On Fri, 9 Dec 2022 12:12:07 -0800 (PST)
N i c o l a s I I T h e B l o o d y <niva...@gmail.com> wrote:
> Thank you Enan, I saw thé profile help but don't happen to find particular
> sample for Cursor move.

That's because there is none. Profiling, as defined in ':h profiling'
only measures the runtime of either a script or a function, not a cursor
move.

I think you're looking for profiling because you want to see which
function call or which command is consuming time when you move the
cursor. If that's correct, you could check what your arrow keys are
mapped to. Remember to invoke these commands from the exact buffer
where arrows keys are slow.

:map <left>
:map <right>
:map <up>
:map <down>

If the arrows are not mapped to any function call or user command, then
the problem is somewhere else; see below.

On Fri, 9 Dec 2022 08:36:18 -0800 (PST)
You wrote:
> Vertical moving cursor with arrow keys on such a file
> like https://github.com/preservim/tagbar/blob/master/autoload/tagbar.vim is
> very very slow.

What did you mean by "such a file"? Do you mean when you open
'tagbar.vim' in vim? or do you mean when you are in the buffer created
by the tagbar plugin? If the latter, then that's a problem with the
plugin and you should open a ticket in its issue tracker.

P.S. The spaces between each letter in your name makes it hard to read.
I would change it to a normal spelling.

Enan Ajmain

unread,
Dec 10, 2022, 7:57:12 AM12/10/22
to niva...@gmail.com, vim...@googlegroups.com
On Sat, 10 Dec 2022 10:16:19 +0100
N i c o l a s I I T h e B l o o d y <niva...@gmail.com> wrote:
> I mean when i open 'tagbar.vim' in vim, about 4500 lines code.
>
> I feel that the pb comes from the call of executable 'ctags': when you move
> Cursor vertically from top to down, it pass through several functions, and
> tagbar wants to show current function Cursor is in. So it calls many times
> 'ctags executable' and this is causes delay on my win11 Os.

That'll do it. Executing binaries in Windows is costly. I don't know
how tagbar works, but if it depends on the output of a system call
without saving the results for using later, it'll be slow in both
versions of VimScript _and_ Lua. I had to deal with a similar situation
for a simple VimL function that made calls to 'git' three-four times. I
solved it by relying on the fugitive plugin. It saves the pertinent
values in buffer-local variables, so my VimL function didn't need to
call the 'git' binary.

To hammer home my point: if fugitive didn't save the frequently-used git
values, vim users couldn't use fugitive in Windows because of how slow
it would be to execute any fugitive command.

Windows is a pain.

> I am currently trying to port tagbar legacy to vim9script. But if i am
> right, the pb will still be there.

Most probably.

> I have noticed your advise Enan.
> Thank
> Nicolas

The name you assigned to your email address still has inter-letter
spaces. See how the attribution text (see at the very beginning of this
email) spells your name with your email address? That name comes from
the From: header of your email, which is set by either your email client
or, if you are using Google's web interface, your Google username.


P.S. You forgot to CC vim-dev list. I'm appending your original email
with this email for posterity; see below after the marker for forwarded
message.
===== Begin forwarded message =====

Date: Sat, 10 Dec 2022 10:16:19 +0100
From: N i c o l a s I I T h e B l o o d y <niva...@gmail.com>
To: Enan Ajmain <3nan....@gmail.com>
Subject: Re: Profile Cursor move (very slow)


I mean when i open 'tagbar.vim' in vim, about 4500 lines code.

I feel that the pb comes from the call of executable 'ctags': when you
move Cursor vertically from top to down, it pass through several
functions, and tagbar wants to show current function Cursor is in. So
it calls many times 'ctags executable' and this is causes delay on my
win11 Os.

I am currently trying to port tagbar legacy to vim9script. But if i am
right, the pb will still be there.

I have noticed your advise Enan.
Thank
Nicolas

Le sam. 10 déc. 2022 à 06:07, Enan Ajmain <3nan....@gmail.com> a
écrit :
===== End forwarded message =====

N i c o l a s

unread,
Dec 11, 2022, 11:05:52 AM12/11/22
to vim_dev
Reply all
Reply to author
Forward
0 new messages