On Sat, Jun 13, 2009 at 12:09 AM, Cháo<[email protected]> wrote:

> Hi all,
> I've got a Ubuntu shared directory mapped as a drive, k drive, in Windows XP
> and whenever I try to save (:w) it takes about 8 to 12 seconds to complete
> the operation for a 133,124 bytes size text file - not acceptable slow.  IF
> I save under Notepad with the same file, it takes about 2 seconds!!
> The share drive is connected through a VPN from work.  I don't have
> swapfiles / backup turn on, so I am not sure what else is causing this
> delay.  I was surprised that notepad had beaten VIM in this situation!  I
> want VIM to kick notepad anytime, so if anyone has any suggestions please
> let me know and I will try it out.  It's been bugging me for some days, is
> this a defect?  In today's network speed, I don't think there would be this
> much delays for saving text files.
> Note: if I write the same size bytes to a new file, it only takes about 6
> seconds, so writing to an existing file over a mapped share drive has more
> overheads / delays.
> Go Vim!
> Thanks,
> Cháo


Hi

Things worth trying:

- What's the speed when running Vim with:  vim -u NONE
  (to rule out anything unexpected hat could be done by a plugin)
- How is the time difference with small files vs large files?
  Is the speed difference proportional to the file size?  Or is
  there a constant slow down regardless of the file size?
  It might be a combination of both.
  It would be useful to have a graph showing write time vs file
  size when using Vim and Notepad.
- things worth trying to check if they help:
    :set noswapfile
    :set nobackup
    :set nowritebackup
    :set nofsync

I tried running Vim with strace on Linux (I don't know any
equivalent on Windows XP) and I see that Vim writes the
file by chunks of 8192 bytes (which sounds reasonable to
me). It corresponds to BUFSIZE macro in src/fileio.c:

#define BUFSIZE         8192    /* size of normal write buffer */

I wonder whether making BUFSIZE bigger could help.
If you can recompile Vim, it might be worth trying to replace
BUFSIZE with something bigger (as an experiment) such as:

#define BUFSIZE         1024*32    /* size of normal write buffer */

Other things I see with strace:

- before writing file, Vim stats the file 4 times (not sure why
  4 times are needed).  For example I did ":w! /tmp/foo.txt" and
  strace -r shows:

     ...snip...
     0.000091 chdir("/tmp")             = 0
     0.000101 getcwd("/tmp", 4096)      = 5
     0.000094 fchdir(6)                 = 0
     0.000086 close(6)                  = 0
!!!  0.000097 stat64("/tmp/foo.txt", {st_mode=S_IFREG|0644,
st_size=423510, ...}) = 0
     0.000185 open(".", O_RDONLY|O_LARGEFILE) = 6
     0.000097 fchdir(6)                 = 0
     0.000085 chdir("/tmp")             = 0
     0.000096 getcwd("/tmp", 4096)      = 5
     0.000092 fchdir(6)                 = 0
     0.000083 close(6)                  = 0
!!!  0.000090 stat64("/tmp/foo.txt", {st_mode=S_IFREG|0644,
st_size=423510, ...}) = 0
     0.000345 stat64("/tmp/foo.txt", {st_mode=S_IFREG|0644,
st_size=423510, ...}) = 0
     0.000191 readlink("/tmp/foo.txt", 0xbf836fe4, 4095) = -1 EINVAL
(Invalid argument)
!!!  0.000125 stat64("/tmp/.foo.txt.swp", 0xbf837f88) = -1 ENOENT (No
such file or directory)
     0.000180 write(1, "\33[?25l\"/tmp/foo.txt\" \33[34;16H\33[K", 32) = 32
!!!  0.000133 stat64("/tmp/foo.txt", {st_mode=S_IFREG|0644,
st_size=423510, ...}) = 0
     0.000178 access("/tmp/foo.txt", W_OK) = 0
     0.000206 getxattr("/tmp/foo.txt", "system.posix_acl_access",
0xbf838f10, 132) = -1 EOPNOTSUPP (Operation not supported)
     0.000209 open("/tmp/foo.txt",
O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0644) = 6

     ... and then follow a bunch of writes of 8192 bytes on file
descriptor 6 (/tmp/foo.txt)...

     0.000384 fsync(6)                  = 0
     0.024673 close(6)                  = 0

Cheers
-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to