From bf99114024db505e8745b18857a84adcd949657b Mon Sep 17 00:00:00 2001 From: Pavel Kalinnikov Date: Wed, 10 Aug 2022 18:36:15 +0100 Subject: [PATCH] kvserver: instrument RaftTransport workers with pprof labels The unused arguments in the method signature were used to identify goroutines in traces. This no longer works after Go 1.17 started passing arguments via registers. This commit adds pprof labels when starting these goroutines, to have a cleaner code, more readable traces, and to work around the new Go convention. Release note: None --- pkg/kv/kvserver/raft_transport.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/kv/kvserver/raft_transport.go b/pkg/kv/kvserver/raft_transport.go index 1d22b5124413..566a834715e0 100644 --- a/pkg/kv/kvserver/raft_transport.go +++ b/pkg/kv/kvserver/raft_transport.go @@ -13,6 +13,7 @@ package kvserver import ( "context" "net" + "runtime/pprof" "time" "unsafe" @@ -373,10 +374,7 @@ func (t *RaftTransport) Stop(storeID roachpb.StoreID) { // lost and a new instance of processQueue will be started by the next message // to be sent. func (t *RaftTransport) processQueue( - nodeID roachpb.NodeID, - ch chan *kvserverpb.RaftMessageRequest, - stream MultiRaft_RaftMessageBatchClient, - class rpc.ConnectionClass, + ch chan *kvserverpb.RaftMessageRequest, stream MultiRaft_RaftMessageBatchClient, ) error { errCh := make(chan error, 1) @@ -566,11 +564,14 @@ func (t *RaftTransport) startProcessNewQueue( return } - if err := t.processQueue(toNodeID, ch, stream, class); err != nil { + if err := t.processQueue(ch, stream); err != nil { log.Warningf(ctx, "while processing outgoing Raft queue to node %d: %s:", toNodeID, err) } } - err := t.stopper.RunAsyncTask(ctx, "storage.RaftTransport: sending messages", worker) + err := t.stopper.RunAsyncTask(ctx, "storage.RaftTransport: sending/receiving messages", + func(ctx context.Context) { + pprof.Do(ctx, pprof.Labels("remote_node_id", toNodeID.String()), worker) + }) if err != nil { t.queues[class].Delete(int64(toNodeID)) return false