Skip to content

Commit

Permalink
time detail merge
Browse files Browse the repository at this point in the history
Signed-off-by: cfzjywxk <[email protected]>
  • Loading branch information
cfzjywxk committed Apr 3, 2024
1 parent 125a140 commit 81a74ad
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions util/execdetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ func (td *TimeDetail) String() string {
return ""
}
buf := bytes.NewBuffer(make([]byte, 0, 16))
buf.WriteString("time_detail: {")
if td.ProcessTime > 0 {
buf.WriteString("total_process_time: ")
buf.WriteString(FormatDuration(td.ProcessTime))
Expand Down Expand Up @@ -667,17 +668,19 @@ func (td *TimeDetail) String() string {
buf.WriteString("tikv_wall_time: ")
buf.WriteString(FormatDuration(td.TotalRPCWallTime))
}
buf.WriteString("}")
return buf.String()
}

// Merge merges the time detail into itself.
// Note this function could be called concurrently.
func (td *TimeDetail) Merge(detail *TimeDetail) {
if detail != nil {
td.ProcessTime += detail.ProcessTime
td.SuspendTime += detail.SuspendTime
td.WaitTime += detail.WaitTime
td.KvReadWallTime += detail.KvReadWallTime
td.TotalRPCWallTime += detail.TotalRPCWallTime
atomic.AddInt64((*int64)(&td.ProcessTime), int64(detail.ProcessTime))
atomic.AddInt64((*int64)(&td.SuspendTime), int64(detail.SuspendTime))
atomic.AddInt64((*int64)(&td.WaitTime), int64(detail.WaitTime))
atomic.AddInt64((*int64)(&td.KvReadWallTime), int64(detail.KvReadWallTime))
atomic.AddInt64((*int64)(&td.TotalRPCWallTime), int64(detail.TotalRPCWallTime))
}
}

Expand Down

0 comments on commit 81a74ad

Please sign in to comment.