Skip to content

Commit 8d598cb

Browse files
craig[bot]cthumuluru-crdb
andcommitted
Merge #147303
147303: server: avoid allocation while creating gRPC heartbeat client r=cthumuluru-crdb a=cthumuluru-crdb Avoid allocation while creating gRPC heartbeat client. Fixes: none Epic: CRDB-48923 Release note: none Co-authored-by: Chandra Thumuluru <[email protected]>
2 parents 01c9276 + 23f6d68 commit 8d598cb

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

pkg/rpc/grpc.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ func (g *grpcCloseNotifier) CloseNotify(ctx context.Context) <-chan struct{} {
4646
return ch
4747
}
4848

49-
type grpcHeartbeatClient struct {
50-
c HeartbeatClient
51-
}
49+
type grpcHeartbeatClient heartbeatClient
5250

5351
func (g *grpcHeartbeatClient) Ping(ctx context.Context, in *PingRequest) (*PingResponse, error) {
54-
return g.c.Ping(ctx, in)
52+
return (*heartbeatClient)(g).Ping(ctx, in)
5553
}
5654

5755
type GRPCConnection = Connection[*grpc.ClientConn]

pkg/rpc/peer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ func (rpcCtx *Context) newPeer(k peerKey, locality roachpb.Locality) *peer[*grpc
251251
},
252252
dialDRPC: dialDRPC(rpcCtx),
253253
newHeartbeatClient: func(cc *grpc.ClientConn) rpcHeartbeatClient {
254-
return &grpcHeartbeatClient{
255-
c: NewHeartbeatClient(cc),
256-
}
254+
return &grpcHeartbeatClient{cc: cc}
257255
},
258256
newBatchStreamClient: func(ctx context.Context, cc *grpc.ClientConn) (BatchStreamClient, error) {
259257
return kvpb.NewInternalClient(cc).BatchStream(ctx)

0 commit comments

Comments
 (0)