Optimize remote daemon builds and TCP latency

This commit is contained in:
Lawrence Chen 2026-03-13 04:34:58 -07:00
parent 21246c7657
commit b0bfabdb6a
4 changed files with 26 additions and 4 deletions

View file

@ -507,6 +507,7 @@ func dialTCPRetry(addr string, timeout time.Duration, refreshAddr func() string)
for {
conn, err := net.DialTimeout("tcp", addr, 2*time.Second)
if err == nil {
setTCPNoDelay(conn)
return conn, addr, nil
}
if time.Now().After(deadline) {

View file

@ -173,6 +173,14 @@ func runStdioServer(stdin io.Reader, stdout io.Writer) error {
}
}
func setTCPNoDelay(conn net.Conn) {
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return
}
_ = tcpConn.SetNoDelay(true)
}
func readRPCFrame(reader *bufio.Reader, maxBytes int) ([]byte, bool, error) {
frame := make([]byte, 0, 1024)
for {
@ -345,6 +353,7 @@ func (s *rpcServer) handleProxyOpen(req rpcRequest) rpcResponse {
},
}
}
setTCPNoDelay(conn)
s.mu.Lock()
streamID := fmt.Sprintf("s-%d", s.nextStreamID)