vim 保存文件时太慢

vim 保存文件时太慢

我在 Linux CentOS 5.3 下运行 vi。每次退出文件时,我都必须等待几秒钟才能保存文件。 vim 也会发生同样的事情。

我运行了这个命令:

strace -odetails -ff -f -r -v vi test

这是日志文件中显示较长延迟(16 秒)的部分。延迟并不总是相同:

 0.000041 write(1, "q", 1)          = 1     0.000040 select(1, [0], NULL, [0], {4, 0}) = 1 (in [0], left {3, 737000})     0.262932 select(1, [0], NULL, [0], NULL) = 1 (in [0])     0.000055 read(0, "\r", 250)        = 1     0.000047 select(1, [0], NULL, [0], {0, 0}) = 0 (Timeout)     0.000050 write(1, "\r", 1)         = 1
 0.000057 stat64("/root/yyy58/test", 0xbfb50ee8) = -1 ENOENT (No such file or directory)
 0.000060 write(1, "\33[?25l", 6)   = 6     0.000044 ioctl(0, SNDCTL_TMR_START or TCSETS, {c_iflags=0x500, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
 0.000077 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x500, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0     0.000063 write(1, "\"test\"", 6)   = 6     0.000043 stat64("test", 0xbfb511c0) = -1 ENOENT (No such file or directory)     0.000089 open("test", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 4
 0.000089 write(4, "\nsdf\nsf\nsdf\nsd\nfsdf\nsdf\nsdf\ns\nd\n"..., 42) = 42     0.000076 fsync(4)                  = 0
16.520635 stat64("test", {st_dev=makedev(0, 189), st_ino=30549058, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=42, st_atime=2011/08/06-15:59:23, st_mtime=2011/08/06-15:59:23, st_ctime=2011/08/06-15:59:23}) = 0     0.000106 close(4)                  = 0     0.000061 write(1, " [New] 13L, 42C written", 23) = 23     0.000054 _llseek(3, 0, [0], SEEK_SET) = 0     0.000038 write(3, "b0VIM 7.0\0\0\0\0\20\0\0\0\0\0\0\0\0\0\0\345\37\0\0root"..., 4096) = 4096     0.000055 stat64("/root/yyy58/test", {st_dev=makedev(0, 189), st_ino=30549058, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=42, st_atime=2011/08/06-15:59:23, st_mtime=2011/08/06-15:59:23, st_ctime=2011/08/06-15:59:23}) = 0     0.000089 write(1, "\r\r\n\33[?1l\33>", 10) = 10     0.000042 write(1, "\33[?12l\33[?25h\33[?1049l", 20) = 20
 0.000036 close(3)                  = 0
 0.000030 unlink("/root/yyy58/.test.swp") = 0     0.000150 exit_group(0)             = ?

我该如何解决这个问题或更好地追踪问题?

答案1

当我的主目录中存在陈旧/缓慢的 sftp+FUSE 挂载时,我经常遇到类似的问题;我会先检查一下。

相关内容