Profiling VIM and/or displaying current action

6 views
Skip to first unread message

WL

unread,
Feb 22, 2009, 10:59:27 AM2/22/09
to vim_use
Hi,

The motivation for my question is as follows. I use VIM mainly for C++
dev on Linux. Over the years it grew to be heavily configured ( > 700
lines .vimrc) and to use quite a few scripts.

Recently I'm experiencing "freezes" of VIM. Meaning, while editing or
executing an ex command VIM will freeze. It will not respond to any
further commands. It does not show or update what its doing. Usually I
wait a min. or two and can then cont. working. This leads me to two,
possibly related questions.

1. Is there a way to profile VIM so that I could find the culprit
script or .vimrc line?

2. Does VIM support a way to display the action its currently doing or
give some kind of feedback that its still alive when performing time
consuming tasks?

TIA,
Yosi

Nazri Ramliy

unread,
Feb 22, 2009, 11:38:04 AM2/22/09
to vim...@googlegroups.com
On Sun, Feb 22, 2009 at 11:59 PM, WL <iza...@gmail.com> wrote:
> 1. Is there a way to profile VIM so that I could find the culprit
> script or .vimrc line?
>
> 2. Does VIM support a way to display the action its currently doing or
> give some kind of feedback that its still alive when performing time
> consuming tasks?

I don't know the answers to those two. I'd just like to give a
suggestion (maybe you've tried it already in that case just ignore the
following).

Run strace on vim on another terminal and as soon as that problem
happens see what's up in that strace output. It might give a clue.

nazri.

Andreas Bernauer

unread,
Feb 22, 2009, 1:04:04 PM2/22/09
to vim...@googlegroups.com
Nazri Ramliy wrote:
> On Sun, Feb 22, 2009 at 11:59 PM, WL <iza...@gmail.com> wrote:
>> 1. Is there a way to profile VIM so that I could find the culprit
>> script or .vimrc line?
>>
>> 2. Does VIM support a way to display the action its currently doing or
>> give some kind of feedback that its still alive when performing time
>> consuming tasks?
>
> Run strace on vim on another terminal and as soon as that problem
> happens see what's up in that strace output. It might give a clue.

You could also attach gdb to the vim process and check the backtrace.

--
Andreas.

Dominique Pelle

unread,
Feb 22, 2009, 2:36:26 PM2/22/09
to vim...@googlegroups.com
WL wrote:


Which version of Vim are you using? I recommend compiling
the latest version of Vim (Vim-7.2.121 as of today) to get all
latest bug fixes.

For example, following recent patch fixed a endless loop:

7.2.106 endless loop for "]s" in HTML when there are no misspellings

Now to answer your questions:

> 1. Is there a way to profile VIM so that I could find the culprit
> script or .vimrc line?

You can profile Vim itself with gprof or you can also profile vim
scripts with the profiler builtin feature in Vim (see :help profile).
If this feature is built in Vim command :version should output
+profile.

> 2. Does VIM support a way to display the action its currently doing or
> give some kind of feedback that its still alive when performing time
> consuming tasks?

:help 'verbose'

If it hangs, you can also attach with gdb and look at the stack:

$ gdb vim PID
(gdb) bt

where:

- vim is the full pathname of the Vim executable (compiled
with debug information and without optimization to get useful
output with gdb).

- PID is the process ID of the Vim process running (which hangs).

As someone mentioned, strace may also be useful.

-- Dominique

Tom Link

unread,
Feb 22, 2009, 3:06:07 PM2/22/09
to vim_use
> :help 'verbose'

If a vim command is responsible for this, you could set verbose=15,
which would display every ex command being processed. You could then
log that output to a file by means of the verbosefile option.

tom

yosi izaq

unread,
Feb 23, 2009, 7:41:26 AM2/23/09
to vim...@googlegroups.com
On Sun, Feb 22, 2009 at 9:36 PM, Dominique Pelle wrote:
> If it hangs, you can also attach with gdb and look at the stack:
>
> $ gdb vim PID
> (gdb) bt
>

Doesn't work on my system for some reason. I get:
[yizaq@yizaq-lnx:Mon Feb 23:~]$ which vim
/usr/local/bin/vim
[yizaq@yizaq-lnx:Mon Feb 23:~]$ sudo gdb /usr/local/bin/vim 3693
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...(no debugging
symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".

Attaching to program: /usr/local/bin/vim, process 3693
ptrace: Operation not permitted.
/users/yizaq/3693: No such file or directory.

I'll give the other options a try.

Thanks,
Yosi

yosi izaq

unread,
Feb 23, 2009, 7:45:26 AM2/23/09
to vim...@googlegroups.com
On Sun, Feb 22, 2009 at 6:38 PM, Nazri Ramliy wrote:
>
>
> Run strace on vim on another terminal and as soon as that problem
> happens see what's up in that strace output. It might give a clue.
>


Alas, this doesn't seem to give much info. I get:
[yizaq@yizaq-lnx:Mon Feb 23:~]$ ps -ef | grep yizaq | grep gvim
yizaq 3693 1 0 Jan06 ? 00:00:00 gvim -font Courier Bold 13 -d

[yizaq@yizaq-lnx:Mon Feb 23:~]$ sudo strace -p 3693
Process 3693 attached - interrupt to quit
ioctl(3, FIONREAD, [0]) = 0
poll(


Of course I tried to do a number of actions. Open buffers, alternate,
execute shell commands from within vim. The strace is silent.
Probably doing something wrong.

Thanks,
Yosi

Tony Mechelynck

unread,
Feb 24, 2009, 10:56:17 AM2/24/09
to vim...@googlegroups.com
On 22/02/09 20:36, Dominique Pelle wrote:
> WL wrote:
[...]

> Which version of Vim are you using? I recommend compiling
> the latest version of Vim (Vim-7.2.121 as of today) to get all
> latest bug fixes.

This is a good counsel for any problem: if you aren't using the latest
version/patchlevel, try getting it (7.2.127 as of today), maybe your
problem was solved in the meantime. If your current version is only a
few patchlevels from the latest one, look at the bottom of
http://ftp.vim.org/pub/vim/patches/7.2/README to see if any of the
intervening patches looks promising. (That README file has a one-line
summary for every patch to the current version.)

>
> For example, following recent patch fixed a endless loop:
>
> 7.2.106 endless loop for "]s" in HTML when there are no misspellings
>
> Now to answer your questions:
>
>> 1. Is there a way to profile VIM so that I could find the culprit
>> script or .vimrc line?
>
> You can profile Vim itself with gprof or you can also profile vim
> scripts with the profiler builtin feature in Vim (see :help profile).
> If this feature is built in Vim command :version should output
> +profile.

[...]

If you have a version with -profile, install (or compile) a Huge version
of Vim -- according to ":help +feature-list", the profiling feature is
at the moment the only difference (all other things being equal) between
Big and Huge builds. (On Windows, Steve Hall's Vim distributions hosted
on the Cream project site include Big builds, so even on Windows, you'll
probably have to compile it yourself. See the Compiling HowTo pages for
Windows or Unix/Linux on my Vim site
http://users.skynet.be/antoine.mechelynck/vim/ for details.)


Best regards,
Tony.
--
Oregon, n.:
Eighty billion gallons of water with no place to go on Saturday
night.

Reply all
Reply to author
Forward
0 new messages