functions polling files over slow connections

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

functions polling files over slow connections

Steve Hall-4

Hello,

I've recently run into a problem where two Vim functions appear to be
causing unexplained (or unreasonable) sluggishness over high-latency
connections:

    filewritable(expand("%"))
    getbufvar(bufnr, "&modified")

I use these to produce various symbols indicating file state, the
first for the window title, the second in the statusline. However it
appears that both cause Vim to poll the file quite often, several
times a second. This produces an unusable sluggishness for files
opened at a remote location.

Obviously, the simple solution is to remove these for high latency
situations. (Although doing so automatically is quite a problem, what
defines "slow" and how could Vim deduce it?) But I am wondering if
this is a bug that the poll occurs so often. Or is this frequency
controllable? Also, why would the second function above even need to
verify against the remote file state when it is only supposed to be
looking at a (local) memory buffer?

Thanks for any insights.


--
Steve Hall  [ digitect mindspring com ]


Reply | Threaded
Open this post in threaded view
|

Re: functions polling files over slow connections

Bram Moolenaar

Steve Hall wrote:

> I've recently run into a problem where two Vim functions appear to be
> causing unexplained (or unreasonable) sluggishness over high-latency
> connections:
>
>     filewritable(expand("%"))
>     getbufvar(bufnr, "&modified")
>
> I use these to produce various symbols indicating file state, the
> first for the window title, the second in the statusline. However it
> appears that both cause Vim to poll the file quite often, several
> times a second. This produces an unusable sluggishness for files
> opened at a remote location.
>
> Obviously, the simple solution is to remove these for high latency
> situations. (Although doing so automatically is quite a problem, what
> defines "slow" and how could Vim deduce it?) But I am wondering if
> this is a bug that the poll occurs so often. Or is this frequency
> controllable? Also, why would the second function above even need to
> verify against the remote file state when it is only supposed to be
> looking at a (local) memory buffer?

It is unlikely to be a bug.  Expanding a file name involves stat() calls
to figure out the full name of a file, going up the directory tree.

The getbufvar() call itself should not need to touch the file system,
but perhaps this happens when you figure out the buffer number?  That
might involve comparing file names, using stat() to compare inode/device
numbers (required for when there is a symlink).

--
hundred-and-one symptoms of being an internet addict:
232. You start conversations with, "Have you gotten an ISDN line?"

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: functions polling files over slow connections

Steve Hall-4
In reply to this post by Steve Hall-4
From: Bram Moolenaar, Sep 13, 2005 5:39 AM
> Steve Hall wrote:
>
> > I've recently run into a problem where two Vim functions appear to
> > be causing unexplained (or unreasonable) sluggishness over
> > high-latency connections:
> >
> >     filewritable(expand("%"))
> >     getbufvar(bufnr, "&modified")
> >
[snip]
>
> It is unlikely to be a bug.  Expanding a file name involves stat()
> calls to figure out the full name of a file, going up the directory
> tree.

Ah, that's it, both of my conditions expand the filename.

Thanks.

--
Steve Hall  [ digitect mindspring com ]