From 2995d7416a3a04f694eb7e203402e3d5bc1f1bf0 Mon Sep 17 00:00:00 2001 From: Andrei Matei Date: Sat, 20 May 2023 12:08:47 -0400 Subject: [PATCH] rpc2, debugger: Fix comments around goroutine grouping --- service/debugger/debugger.go | 19 ++++++++++++++----- service/rpc2/server.go | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/service/debugger/debugger.go b/service/debugger/debugger.go index af5eb5c1b1..ff921642a1 100644 --- a/service/debugger/debugger.go +++ b/service/debugger/debugger.go @@ -1683,10 +1683,19 @@ func formatLoc(loc proc.Location) string { return fmt.Sprintf("%s:%d in %s", loc.File, loc.Line, fnname) } -// GroupGoroutines divides goroutines in gs into groups as specified by groupBy and groupByArg. -// A maximum of maxGoroutinesPerGroup are saved in each group, but the total -// number of goroutines in each group is recorded. -func (d *Debugger) GroupGoroutines(gs []*proc.G, group *api.GoroutineGroupingOptions) ([]*proc.G, []api.GoroutineGroup, bool) { +// GroupGoroutines divides goroutines in gs into groups as specified by +// group.{GroupBy,GroupByKey}. A maximum of group.MaxGroupMembers are saved in +// each group, but the total number of goroutines in each group is recorded. If +// group.MaxGroups is set, then at most that many groups are returned. If some +// groups end up being dropped because of this limit, the tooManyGroups return +// value is set. +// +// The first return value represents the goroutines that have been included in +// one of the returned groups (subject to the MaxGroupMembers and MaxGroups +// limits). The second return value represents the groups. +func (d *Debugger) GroupGoroutines( + gs []*proc.G, group *api.GoroutineGroupingOptions, +) (_ []*proc.G, _ []api.GoroutineGroup, tooManyGroups bool) { if group.GroupBy == api.GoroutineFieldNone { return gs, nil, false } @@ -1726,7 +1735,7 @@ func (d *Debugger) GroupGoroutines(gs []*proc.G, group *api.GoroutineGroupingOpt } sort.Strings(keys) - tooManyGroups := false + tooManyGroups = false gsout := []*proc.G{} groups := []api.GoroutineGroup{} for _, key := range keys { diff --git a/service/rpc2/server.go b/service/rpc2/server.go index eedc069238..e178e79f84 100644 --- a/service/rpc2/server.go +++ b/service/rpc2/server.go @@ -657,7 +657,7 @@ type ListGoroutinesOut struct { // be grouped with the specified criterion. // If the value of arg.GroupBy is GoroutineLabel goroutines will // be grouped by the value of the label with key GroupByKey. -// For each group a maximum of MaxExamples example goroutines are +// For each group a maximum of MaxGroupMembers example goroutines are // returned, as well as the total number of goroutines in the group. func (s *RPCServer) ListGoroutines(arg ListGoroutinesIn, out *ListGoroutinesOut) error { //TODO(aarzilli): if arg contains a running goroutines filter (not negated)