Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Submit the tcpnodelay Configuration Switch
Performance Optimization:
The server sends the SSH2_MSG_CHANNEL_OPEN_CONFIRMATION message immediately after sending the public key information (SSH2_MSG_GLOBAL_REQUEST).However, the client does not need to send any message (the SSH2_MSG_CHANNEL_Open and SSH2_MSG_GLOBAL_REQUEST messages have been sent). Therefore, after the client receives the message, the kernel waits for 40 ms to send an ACK message(due to the Nagle's algorithm). As a result, the server kernel needs to wait until the ACK with a delay of 40 ms is received when sending SSH2_MSG_CHANNEL_OPEN_CONFIRMATION.
In fact, the client and server set the socket status to TCP_NODELAY after the channel is established (received).
We will set TCP_NODELAY in advance until after authentication is complete.
We can also add a configuration option. When users are sensitive to performance, TCP_NODELAY is set after the TCP connection between the server and client is established.
This modification results in a 20% performance improvement in frequent short-connection environments.
An SSH connection takes about 200 ms. Setting TCP_NODELAY can optimize the performance of 40 ms.