openssh-portable icon indicating copy to clipboard operation
openssh-portable copied to clipboard

set tcp_nodelay

Open bitianyuan123 opened this issue 11 months ago • 3 comments

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.

bitianyuan123 avatar Jan 14 '25 11:01 bitianyuan123

https://bugzilla.mindrot.org/show_bug.cgi?id=3768

bitianyuan123 avatar Jan 14 '25 12:01 bitianyuan123

@djmdjm Can you review the pull request?

bitianyuan123 avatar Jan 22 '25 01:01 bitianyuan123

@djmdjm @daztucker hello, can you review the pull request?

bitianyuan123 avatar Feb 18 '25 02:02 bitianyuan123

We already unconditionally set nodelay fairly early on the connection socket (e.g. here). Is there some path where this isn't happening?

djmdjm avatar Nov 25 '25 02:11 djmdjm

The issue has been fixed. OpenBSD-Commit-ID: 325fc41717eecdf5e4b534bfa8d66817425b840f

bitianyuan123 avatar Nov 25 '25 06:11 bitianyuan123