Are you using
tmux, a graphical Linux desktop and are you experiencing random sluggishness when starting your editor? If not, you can skip this one.
This is something that had been bugging me for ages, first at work on my workstation, then at home: Long-running
tmux sessions would sporadically induce startup delays of the
vim editor of exactly one second. Reattaching
tmux didn't solve the problem; logging out and back into my desktop always did.
First I thought I was just being impatient, but after some profiling with
time, I was getting curious.
strace revealed that the delay was exactly one second: Something in
vims startup process was calling the
nanosleep(2) system call with one second as an argument!
To make a long story short: This is caused by some X library that is mislead by a broken environment variable
SESSION_MANAGER from a former X session.
tmux tends to get rather attached to environment variables, which, in this instance, causes the sluggishness.
If the problem goes away after executing
or something similar for your shell, you can fix it permanently by appending the following line to your
set-option -g -a update-environment " SESSION_MANAGER"
If you are now wondering why
vim would need access to some X-related variables in the first place (as I was): It lets
vim access your X clipboard! (Strangely, the variable
SESSION_MANAGER is not actually needed for that, but you can verify it by overwriting some more critical X variable like
XAUTHORITY and subsequently trying to use the X clipboard from within