How to check why Vim is slow
On *nix, some processes may not be able to start up, software runs very slowly suddenly and software's "Segment Fault" are some issues faced by many *nix users. Here we show you how to use truss to trace why Vim becomes slow suddenly.
Operating system : FreeBSD-5.2.1-releas
vim version is 6.2.154, after typing vim on command line, sometimes we need to wait for a few minutes to get into the edit interface and there is no error output. After carefully checking .vimrc and all vim settings, there are no error configuration. Also there are no similar solutions online. Do we need to hack the source code? Not necessary, we can use truss to find the issue:
# truss -f -D -o vim.truss vim |
Here the meaning of -D is : Add timestamp offset at beginning of each line of output, i.e the time spent for each line of command, We only need to trace which system calls take long time, use less command to show the vim.truss file:
735: 0.000021511 socket(0x2,0x1,0x0) = 4 (0x4)
735: 0.000014248 setsockopt(0x4,0x6,0x1,0xbfbfe3c8,0x4) = 0 (0x0)
735: 0.000013688 setsockopt(0x4,0xffff,0x8,0xbfbfe2ec,0x4) = 0 (0x0)
735: 0.000203657 connect(0x4,{ AF_INET 10.57.18.27:6000 },16) ERR#61 'Connection refused'
735: 0.000017042 close(4) = 0 (0x0)
735: 1.009366553 nanosleep(0xbfbfe468,0xbfbfe460) = 0 (0x0)
735: 0.000019556 socket(0x2,0x1,0x0) = 4 (0x4)
735: 0.000013409 setsockopt(0x4,0x6,0x1,0xbfbfe3c8,0x4) = 0 (0x0)
735: 0.000013130 setsockopt(0x4,0xffff,0x8,0xbfbfe2ec,0x4) = 0 (0x0)
735: 0.000272102 connect(0x4,{ AF_INET 10.57.18.27:6000 },16) ERR#61 'Connection refused'
735: 0.000015924 close(4) = 0 (0x0)
735: 1.009338338 nanosleep(0xbfbfe468,0xbfbfe460) = 0 (0x0)
|
From above output, we can find vim is trying to connect to the host 10.57.18.27 at port 6000(connect() in line 4), after failure, it sleeps one second and try it again. This process continues for over 10 times, each time it will take more than 1 second. This is the reason why vim becomes slow. But you may have a doubt why vim will connect to other host at its port 6000. Please think about what service uses port 6000, that's X Server, it seems that vim is redirecting its output to a remote X Server. Now we only need to check the DISPLAY variable in Shell, check cshrc, there may be one line like setenv DISPLAY ${REMOTEHOST}:0, comment this line and try to run vim again.
You can use truss to trace other issues as well when launching programs.
Reference : http://www.ibm.com/developerworks/cn/linux/l-tsl/
By clicking the "Mark as important" button, this article will be put to your important article list which you can find in "Amin->Article important list". Later when you want reread this article, it's easier for you to find it by checking the "Article important list".
Tags:vim, truss, linux Read(444) Comment(0)
Previous : 5 million units of Galaxy Note II are sold until now Next : Gmail supports 10 GB attachment after integrating with Google Drive
::Related Articles
::Comment List
No comment for this article.
::Comment
:: Users edited this page
No users edited this page yet.
:: Recent articles
- Meta tag in HTML header
- Text editor vs IDE
- Sorry, I don't want to download your fucking app
- Display GIF animation while submitting the web form
- PHP to get access token for Sina Weibo app
- Tencent released Q1 earning report of 2013
- How to be jQuery-free?
- Programmer's Mother's Day
- Android socket programming example
- this in JavaScript in detail
- more>>
:: Most read
- TIOBE : C overtakes Java as the No.1 programming language
- Which programming language should I learn first?
- Sony is to release PlayStation4 in 2015
- Disposable Email address
- 5 Free Open Source Chat Applications For Developers
- Never ever touch a programmer
- Hacking Vs. Programming
- TIOBE : Where is that next big programming language?
- Multitasking vs multiprogramming
- Google is developing advanced programming technology to simplify Web application development
- more>>
:: Most commented
- Sony is to release PlayStation4 in 2015
- Hacking Vs. Programming
- Which programming language should I learn first?
- Error handling style in C
- 10 controversial programming opinions?
- C vs Java Complete Comparison
- Google+ is sick
- Unix Philosophy
- Disposable Email address
- A C++ program puzzle
- more>>
:: Find us
