← Back to Upcase

Performance issues with Vim, Tmux and iTerm

Greetings upcasers & thoughtbotters!

I was wondering did any of you had any performance issues with Vim (terminal MacVim) + tmux + iterm?

I’m experiencing some pretty noticeable lag when using vim in iTerm. This also drew me to start using gui macvim, but I miss the whole terminal (development) environment. I recently went all in on experimenting with my vimrc, but no matter what I do I can’t improve vim’s responsiveness. It’s still quite slow.
I reduced my config and plugins list as much as I could, went through dozens of “vim optimization” blog posts, and still, nothing helped.

What stuns me even more is the fact that in every upcase/thoughtbot video everyone are using vim in terminal without any issues at all.
Not to mention @christoomey 's dotfiles which are huge, and still, every video shows him “flying” through all the vim’s magic with no lag/delay/slowness whatsoever.

Another thing that makes me wonder where I went wrong with my configs is that this issue keeps me haunting on multiple mbp machines (mid-2014 13" and mid-2015 15" - both standard ones)

So, I present you with my vimrc, vim boot time log and tmux config:

vimrc
tmux.conf
vim boot log

Other info:
iTerm2 Build 2.1.4
OSX 10.11.1 (El Capitan)

Apologies in advance for somewhat not-nicely formatted .vimrc, this is the result of long experimenting.

Big thanks to anyone could provide me with any useful info, no matter how small…

What plugins did you try to remove? And how did you go about it?

Where do you see the lag? Is it in regular typing, switching windows? Just bootup?

I googled lazyredraw which pointed me to this: https://github.com/tpope/vim-sensible/issues/78
especially the comment of kecebongsoft is interesting.

In addition to @sajoku’s questions, here are a few more that might help:

  1. Is the slowness consistent when running inside tmux vs not?
  2. Can you try starting Vim with vim -u NONE. This loads without your Vimrc, so this can give high level view of that.

I was experiencing a performance issue after upgrade to ElCaptain.

The issue https://trac.macports.org/ticket/49121 in MacPorts.

Build from source has resolved the problem for me. Be aware that new version breaks mouse settings by introducing a new config option name.

@aradunovic Did you ever resolve your performance issues?
If so it would be really helpful to other people if you posted your strategy and solution here :smile:
If not, is there anything “we” can help you with to further the research/debugging?

Starting vim with the --startuptime time.log flag can be useful to see what parts of your system started slowest. The second column is each piece’s individual contribution to the startup time for Vim.

1 Like

Thank you all for your replies. Sorry for not being able to respond in quite some time. I’ve been busy as hell.

In the meantime I’ve made a switch to Neovim with addition of vim-test, neoterm and fzf plugins. This setup made tmux (almost) obsolete for my everyday work, including some of the vim plugins I was using earlier.
I’m not experiencing any performance issues whatsoever.

However, for future reference and possibility of helping someone with similar problems, I’ll answer your questions:

@sajoku

  • There were so many plugins I installed and removed during this whole process, I can’t even remember. I was always managing my plugins with Plug (install/clean).

  • The lag is present in autocomplete, opening files with more than around 200 LOC, opening files after searching with CtrlP, etc…

  • I went through that lazyredraw issue, removed the setting and nothing changed

@christoomey

  • The slowness is even more noticeable when running inside tmux
  • Without loading vimrc, everything runs smoothly. I didn’t have enough time lately to go through with the enabling setting by setting…I realize this is my best shot to find the cause of the issue.
  • One more thing, I installed thoughtbot’s laptop script with dotfiles and the lag was very much present.

@bambycha

  • The issue was present even while I was on Yosemite. I haven’t tried building Vim from source, though.

I see now there are couple of more things I could try to resolve this issue. So, I’ll try enabling settings and plugins one by one and see what happens. If I come up with nothing I’ll try building from source. Either way, I’ll report my findings here!!!

I just ran through the tmux trail and ran into a very similar issue. Vim would run perform normally until the either the iterm window was resized or the window was split from tmux. At which point Vim would become unbearably laggy and unusable.

The lag would persist even after closing the window/pane and even session. The only way to fix it was to close iterm completely and re launch. Vim would perform normally until the iterm window would be resized.

Removing all plugins didn’t resolve the issue and would occur outside of tmux sessions. Which is odd, since I wasn’t experiencing this prior to installing tmux.

I discovered that setting lazyredraw in addition to ttyfast in my .vimrc solved the problem even with all my plugins re-enabled.

set nocompatible
set ttyfast
set lazyredraw
...

StackOverflow related question

**Other Info:
iTerm2 - Build 2.1.4
OSX - 10.11.3
Vim - 7.4.1257 (installed with brew)
Python - 2.7.11