Optimize remote daemon builds and TCP latency
This commit is contained in:
parent
21246c7657
commit
b0bfabdb6a
4 changed files with 26 additions and 4 deletions
|
|
@ -1997,7 +1997,9 @@ private final class WorkspaceRemoteDaemonProxyTunnel {
|
|||
NSLocalizedDescriptionKey: "invalid local proxy port \(port)",
|
||||
])
|
||||
}
|
||||
let parameters = NWParameters.tcp
|
||||
let tcpOptions = NWProtocolTCP.Options()
|
||||
tcpOptions.noDelay = true
|
||||
let parameters = NWParameters(tls: nil, tcp: tcpOptions)
|
||||
parameters.allowLocalEndpointReuse = true
|
||||
parameters.requiredLocalEndpoint = .hostPort(host: NWEndpoint.Host("127.0.0.1"), port: localPort)
|
||||
return try NWListener(using: parameters)
|
||||
|
|
@ -2719,7 +2721,9 @@ private final class WorkspaceRemoteCLIRelayServer {
|
|||
}
|
||||
|
||||
private static func makeLoopbackListener() throws -> NWListener {
|
||||
let parameters = NWParameters.tcp
|
||||
let tcpOptions = NWProtocolTCP.Options()
|
||||
tcpOptions.noDelay = true
|
||||
let parameters = NWParameters(tls: nil, tcp: tcpOptions)
|
||||
parameters.allowLocalEndpointReuse = true
|
||||
parameters.requiredLocalEndpoint = .hostPort(host: NWEndpoint.Host("127.0.0.1"), port: .any)
|
||||
return try NWListener(using: parameters)
|
||||
|
|
@ -3806,7 +3810,7 @@ private final class WorkspaceRemoteSessionController {
|
|||
let ldflags = "-s -w -X main.version=\(version)"
|
||||
let result = try runProcess(
|
||||
executable: goBinary,
|
||||
arguments: ["build", "-trimpath", "-ldflags", ldflags, "-o", output.path, "./cmd/cmuxd-remote"],
|
||||
arguments: ["build", "-trimpath", "-buildvcs=false", "-ldflags", ldflags, "-o", output.path, "./cmd/cmuxd-remote"],
|
||||
environment: env,
|
||||
currentDirectory: daemonRoot,
|
||||
stdin: nil,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -68,6 +68,14 @@ DAEMON_ROOT="${REPO_ROOT}/daemon/remote"
|
|||
mkdir -p "$OUTPUT_DIR"
|
||||
rm -f "$OUTPUT_DIR"/cmuxd-remote-* "$OUTPUT_DIR"/cmuxd-remote-checksums.txt "$OUTPUT_DIR"/cmuxd-remote-manifest.json
|
||||
|
||||
DAEMON_GO_LDFLAGS="-s -w -X main.version=${VERSION}"
|
||||
DAEMON_GO_BUILD_ARGS=(
|
||||
build
|
||||
-trimpath
|
||||
-buildvcs=false
|
||||
-ldflags "$DAEMON_GO_LDFLAGS"
|
||||
)
|
||||
|
||||
CHECKSUMS_ASSET_NAME="cmuxd-remote-checksums.txt"
|
||||
CHECKSUMS_PATH="${OUTPUT_DIR}/${CHECKSUMS_ASSET_NAME}"
|
||||
MANIFEST_PATH="${OUTPUT_DIR}/cmuxd-remote-manifest.json"
|
||||
|
|
@ -94,7 +102,7 @@ for target in "${TARGETS[@]}"; do
|
|||
GOOS="$GOOS" \
|
||||
GOARCH="$GOARCH" \
|
||||
CGO_ENABLED=0 \
|
||||
go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" \
|
||||
go "${DAEMON_GO_BUILD_ARGS[@]}" \
|
||||
-o "$OUTPUT_PATH" \
|
||||
./cmd/cmuxd-remote
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue