According to your log and my own experiences, "ssh" command is executed several times. On slow connections this could take pretty long for each ssh command. For recent OpenSSH you can try to reuse connections, check this link here and set your ~/.ssh/config as follows (remember to mkdir ~/.ssh/sockets first):
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
Then you need to disable tramp's default ControlMaster settings in your ~/.emacs by
(setq tramp-ssh-controlmaster-options "")
The next thing you will face is the auto-backup problem that Michael mentioned in his reply. My personal solution to this is combining the suggestion of tramp manual here and this emacs wiki, add the following code into ~/.emacs. A new variable disable-tramp-backups is introduced where you can list what kind of tramp connections you don't want to have backups. My following example disabled auto-backup for all tramped files. You can modify it according to my other examples in the comments.
;;(setq disable-tramp-backups nil) ;; allow all tramp files to be backuped
;;(setq disable-tramp-backups '("su" "sudo")) ;; only 'su' and 'sudo'
;;(setq disable-tramp-backups '("ssh" "sftp")) ;; only 'ssh' and 'sftp'
(defvar disable-tramp-backups '(all))
(eval-after-load "tramp"
'(progn
;; Modified from https://www.gnu.org/software/emacs/manual/html_node/tramp/Auto_002dsave-and-Backup.html
(setq backup-enable-predicate
(lambda (name)
(and (normal-backup-enable-predicate name)
;; Disable all tramp backups
(and disable-tramp-backups
(member 'all disable-tramp-backups)
(not (file-remote-p name 'method)))
(not ;; disable backup for tramp with the listed methods
(let ((method (file-remote-p name 'method)))
(when (stringp method)
(member method disable-tramp-backups)))))))
(defun tramp-set-auto-save--check (original)
(if (funcall backup-enable-predicate (buffer-file-name))
(funcall original)
(auto-save-mode -1)))
(advice-add 'tramp-set-auto-save :around #'tramp-set-auto-save--check)
;; Use my ~/.ssh/config control master settings according to https://puppet.com/blog/speed-up-ssh-by-reusing-connections
(setq tramp-ssh-controlmaster-options "")))
The last thing you might need to take care is the hooks or idle-time functions you set in your ~/.emacs. If you ever invoke shell to run commands (e.g. via `shell-command' function ...) in those hooks/idle-time functions, those commands might be passed to remote machine and will be very slow too. You need to wrap those shell commands with the current buffer changed to somewhere else, like the 'scratch' buffer, for example:
(with-current-buffer (get-buffer "*scratch*")
(shell-command "ls -al")) ;; just a sample shell command
If there are still other slow down problems, enable "Enter Debugger on Quit/C-g" option in Emacs. When emacs seems "hanging" there press C-g and see which function it stuck in.
That's about it. Hope this helps. If you find anything else, please also let me know.
emacs -Q
or a minimal init file. – Scott Weldon May 16 '16 at 18:47-Q
got same behaviour – Dfr May 16 '16 at 19:07