Skip to content

Commit 7ae775f

Browse files
committed
sql/rowflow: refactor monitor name
The monitor names created in `(*rowBasedFlow).setupRouter` now use `(*mon.Name).WithID` to add the stream ID to the name instead of allocating a new string. Release note: None
1 parent 9cf04d5 commit 7ae775f

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

pkg/sql/rowflow/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ go_library(
2929
"//pkg/util/tracing",
3030
"//pkg/util/tracing/tracingpb",
3131
"@com_github_cockroachdb_errors//:errors",
32-
"@com_github_cockroachdb_redact//:redact",
3332
"@io_opentelemetry_go_otel//attribute",
3433
],
3534
)

pkg/sql/rowflow/row_based_flow.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/util/log"
2323
"github.com/cockroachdb/cockroach/pkg/util/mon"
2424
"github.com/cockroachdb/errors"
25-
"github.com/cockroachdb/redact"
2625
)
2726

2827
type rowBasedFlow struct {
@@ -461,9 +460,9 @@ func (f *rowBasedFlow) setupRouter(
461460
unlimitedMemMonitors := make([]*mon.BytesMonitor, len(spec.Streams))
462461
diskMonitors := make([]*mon.BytesMonitor, len(spec.Streams))
463462
for i := range spec.Streams {
464-
// TODO(mgartner): Is a StreamID ever greater than math.MaxInt32? If
465-
// not, we can use (*mon.Name).WithID() instead of allocating a string.
466-
mn := mon.MakeName("router" + redact.SafeString(spec.Streams[i].StreamID.String()))
463+
// NB: Stream IDs are indexes into slices, so we'd expect to OOM long
464+
// before a stream ID exceeds 2^31.
465+
mn := mon.MakeName("router").WithID(int32(spec.Streams[i].StreamID))
467466
memoryMonitors[i] = execinfra.NewLimitedMonitor(ctx, f.Mon, &f.FlowCtx, mn.Limited())
468467
unlimitedMemMonitors[i] = execinfra.NewMonitor(ctx, f.Mon, mn.Unlimited())
469468
diskMonitors[i] = execinfra.NewMonitor(ctx, f.DiskMonitor, mn.Disk())

0 commit comments

Comments
 (0)