adam bobrow writes:
> HI,
Hi Adam,
> While connecting a remote host using Tramp, I encounter an
> indeterminate 20 seconds delay after a successful initial connection.
Yes. You seem to have a slow connection to that host (no surpise going
to AWS), but Tramp must support this as well.
> From my understanding, when inspecting the debug log it seems that
> Tramp identifies the remote prompt after about 3 seconds, which I
> assume is just the network latency but then it takes another ~20
> seconds to finally connect.
Yes.
> I'm unsure what's Tramp's actions during these seconds. Your input
> would be appreciated.
I'm inserting all messages with level 6 from your log (these are the
sent commands, and the returned output) plus a comment.
--8<---cut here---start->8---
10:10:42.724900 tramp-call-process (6) # ‘locale -a’ nil *temp*
10:10:42.748631 tramp-call-process (6) # 0
en_NZ
nl_NL.UTF-8
...
10:10:42.748966 tramp-call-process (6) # ‘ssh -G -o ControlMaster=auto 0.0.0.1’
nil nil
10:10:42.760573 tramp-call-process (6) # 0
Pseudo-terminal will not be allocated because stdin is not a terminal.
user bob
hostname 0.0.0.1
...
10:10:42.760697 tramp-call-process (6) # ‘ssh -G -o ControlPath=tramp.%C
0.0.0.1’ nil nil
10:10:42.766693 tramp-call-process (6) # 0
Pseudo-terminal will not be allocated because stdin is not a terminal.
user bob
hostname 0.0.0.1
...
10:10:42.766811 tramp-call-process (6) # ‘ssh -G -o ControlPersist=no 0.0.0.1’
nil nil
10:10:42.772112 tramp-call-process (6) # 0
Pseudo-terminal will not be allocated because stdin is not a terminal.
user bob
hostname 0.0.0.1
port 22
...
--8<---cut here---end--->8---
These are some local commands, where Tramp determines existing locale
encodings and ssh client properties. They are not performance relevant
--8<---cut here---start->8---
10:10:42.783066 tramp-maybe-open-connection (6) # /bin/sh -i
10:10:42.788943 tramp-wait-for-regexp (6) #
#$
10:10:42.789916 tramp-send-command (6) # exec ssh -o ControlMaster=auto -o
ControlPath=tramp.%C -o ControlPersist=no -e none bobrows
10:10:45.360996 tramp-process-actions (6) #
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.19.0-1029-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support:https://ubuntu.com/advantage
System information as of Tue Aug 8 07:10:44 UTC 2023
System load: 0.0Processes: 108
Usage of /: 26.2% of 15.32GB Users logged in: 1
Memory usage: 71%IPv4 address for eth0: 172.31.83.132
Swap usage: 0%
* Ubuntu Pro delivers the most comprehensive open source security and
compliance features.
https://ubuntu.com/aws/pro
Expanded Security Maintenance for Applications is not enabled.
7 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
Last login: Tue Aug 8 06:55:11 2023 from 176.230.32.30
$
--8<---cut here---end--->8---
Tramp established the remote shell. 3 seconds, as you have said.
--8<---cut here---start->8---
10:10:45.361199 tramp-send-command (6) # exec env TERM='dumb'
INSIDE_EMACS='29.1,tramp:2.6.0.29.1' ENV='' HISTFILE=~/.tramp_history
PROMPT_COMMAND='' PS1=///b2d958bbca0546596c9001895132444f\#\$ PS2='' PS3=''
/bin/sh -i
10:10:45.507803 tramp-wait-for-regexp (6) #
///b2d958bbca0546596c9001895132444f#$
--8<---cut here---end--->8---
Tramp opens an interactive shell /bin/sh. This is necessary, because
Tramp cannot know, whether your login shell is POSIX compliant. It sets
also the shell prompt to the random string
"///b2d958bbca0546596c9001895132444f#$" in order to detect it reliably.
Now it checks some shell properties.
--8<---cut here---start->8---
10:10:45.508291 tramp-send-command (6) # (cd ~/) 2>/dev/null; echo
tramp_exit_status $?
10:10:45.652286 tramp-wait-for-regexp (6) #
tramp_exit_status 0
///b2d958bbca0546596c9001895132444f#$
--8<---cut here---end--->8---
Check, whether the remote shell supports tilde expansion.
--8<---cut here---start->8---
10:10:45.653454 tramp-send-command (6) # set +o vi +o emacs
10:10:45.796193 tramp-wait-for-regexp (6) #
///b2d958bbca0546596c9001895132444f#$
--8<---cut here---end--->8---
Remove some shell options for editing.
--8<---cut here---start->8---
10:10:45.796312 tramp-send-command (6) # stty -inlcr -onlcr -echo kill '^U'
erase '^H'
10:10:45.940105 tramp-wait-for-regexp (6) #
///b2d958bbca0546596c9001895132444f#$
--8<---cut