Skip to content

Commit

Permalink
row: move Metrics struct into rowinfra
Browse files Browse the repository at this point in the history
This allows us to break dependency of `execinfra` on `row` which speeds
up the build a bit.

Release note: None
  • Loading branch information
yuzefovich committed Apr 8, 2022
1 parent 15bbd78 commit 060fe6a
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 29 deletions.
6 changes: 3 additions & 3 deletions pkg/sql/backfill/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type ColumnBackfiller struct {
// mon is a memory monitor linked with the ColumnBackfiller on creation.
mon *mon.BytesMonitor

rowMetrics *row.Metrics
rowMetrics *rowinfra.Metrics
}

// initCols is a helper to populate some column metadata on a ColumnBackfiller.
Expand All @@ -111,7 +111,7 @@ func (cb *ColumnBackfiller) init(
computedExprs []tree.TypedExpr,
desc catalog.TableDescriptor,
mon *mon.BytesMonitor,
rowMetrics *row.Metrics,
rowMetrics *rowinfra.Metrics,
) error {
cb.evalCtx = evalCtx
cb.updateCols = append(cb.added, cb.dropped...)
Expand Down Expand Up @@ -171,7 +171,7 @@ func (cb *ColumnBackfiller) InitForLocalUse(
semaCtx *tree.SemaContext,
desc catalog.TableDescriptor,
mon *mon.BytesMonitor,
rowMetrics *row.Metrics,
rowMetrics *rowinfra.Metrics,
) error {
cb.initCols(desc)
defaultExprs, err := schemaexpr.MakeDefaultExprs(
Expand Down
20 changes: 10 additions & 10 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgwirecancel"
"github.com/cockroachdb/cockroach/pkg/sql/physicalplan"
"github.com/cockroachdb/cockroach/pkg/sql/querycache"
"github.com/cockroachdb/cockroach/pkg/sql/row"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scexec"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scrun"
Expand Down Expand Up @@ -1188,8 +1188,8 @@ type ExecutorConfig struct {

SchemaChangerMetrics *SchemaChangerMetrics
FeatureFlagMetrics *featureflag.DenialMetrics
RowMetrics *row.Metrics
InternalRowMetrics *row.Metrics
RowMetrics *rowinfra.Metrics
InternalRowMetrics *rowinfra.Metrics

TestingKnobs ExecutorTestingKnobs
MigrationTestingKnobs *migration.TestingKnobs
Expand Down Expand Up @@ -3324,18 +3324,18 @@ func TestingDescsTxn(
return DescsTxn(ctx, &execCfg, f)
}

// NewRowMetrics creates a row.Metrics struct for either internal or user
// NewRowMetrics creates a rowinfra.Metrics struct for either internal or user
// queries.
func NewRowMetrics(internal bool) row.Metrics {
return row.Metrics{
MaxRowSizeLogCount: metric.NewCounter(getMetricMeta(row.MetaMaxRowSizeLog, internal)),
MaxRowSizeErrCount: metric.NewCounter(getMetricMeta(row.MetaMaxRowSizeErr, internal)),
func NewRowMetrics(internal bool) rowinfra.Metrics {
return rowinfra.Metrics{
MaxRowSizeLogCount: metric.NewCounter(getMetricMeta(rowinfra.MetaMaxRowSizeLog, internal)),
MaxRowSizeErrCount: metric.NewCounter(getMetricMeta(rowinfra.MetaMaxRowSizeErr, internal)),
}
}

// GetRowMetrics returns the proper RowMetrics for either internal or user
// GetRowMetrics returns the proper rowinfra.Metrics for either internal or user
// queries.
func (cfg *ExecutorConfig) GetRowMetrics(internal bool) *row.Metrics {
func (cfg *ExecutorConfig) GetRowMetrics(internal bool) *rowinfra.Metrics {
if internal {
return cfg.InternalRowMetrics
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/execinfra/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ go_library(
"//pkg/sql/catalog/descs",
"//pkg/sql/catalog/tabledesc",
"//pkg/sql/execinfrapb",
"//pkg/sql/row",
"//pkg/sql/rowenc",
"//pkg/sql/rowenc/valueside",
"//pkg/sql/rowinfra",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/tree",
"//pkg/sql/sessiondata",
Expand Down Expand Up @@ -123,6 +123,7 @@ disallowed_imports_test(
"//pkg/sql/colexec",
"//pkg/sql/colflow",
"//pkg/sql/flowinfra",
"//pkg/sql/row",
"//pkg/sql/rowexec",
"//pkg/sql/rowflow",
],
Expand Down
10 changes: 5 additions & 5 deletions pkg/sql/execinfra/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/rpc/nodedialer"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
"github.com/cockroachdb/cockroach/pkg/sql/row"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sqlliveness"
"github.com/cockroachdb/cockroach/pkg/sql/sqlutil"
Expand Down Expand Up @@ -120,8 +120,8 @@ type ServerConfig struct {
ParentDiskMonitor *mon.BytesMonitor

Metrics *DistSQLMetrics
RowMetrics *row.Metrics
InternalRowMetrics *row.Metrics
RowMetrics *rowinfra.Metrics
InternalRowMetrics *rowinfra.Metrics

// SQLLivenessReader provides access to reading the liveness of sessions.
SQLLivenessReader sqlliveness.Reader
Expand Down Expand Up @@ -316,9 +316,9 @@ func GetWorkMemLimit(flowCtx *FlowCtx) int64 {
return flowCtx.EvalCtx.SessionData().WorkMemLimit
}

// GetRowMetrics returns the proper RowMetrics for either internal or user
// GetRowMetrics returns the proper rowinfra.Metrics for either internal or user
// queries.
func (flowCtx *FlowCtx) GetRowMetrics() *row.Metrics {
func (flowCtx *FlowCtx) GetRowMetrics() *rowinfra.Metrics {
if flowCtx.EvalCtx.SessionData().Internal {
return flowCtx.Cfg.InternalRowMetrics
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/sql/row/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ go_library(
"kv_batch_streamer.go",
"kv_fetcher.go",
"locking.go",
"metrics.go",
"partial_index.go",
"row_converter.go",
"truncate.go",
Expand Down Expand Up @@ -66,7 +65,6 @@ go_library(
"//pkg/util/hlc",
"//pkg/util/log",
"//pkg/util/log/eventpb",
"//pkg/util/metric",
"//pkg/util/mon",
"//pkg/util/protoutil",
"//pkg/util/timeutil",
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/row/deleter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/log"
)
Expand Down Expand Up @@ -47,7 +48,7 @@ func MakeDeleter(
requestedCols []catalog.Column,
sv *settings.Values,
internal bool,
metrics *Metrics,
metrics *rowinfra.Metrics,
) Deleter {
indexes := tableDesc.DeletableNonPrimaryIndexes()

Expand Down
5 changes: 3 additions & 2 deletions pkg/sql/row/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc/rowencpb"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/encoding"
Expand Down Expand Up @@ -109,7 +110,7 @@ type rowHelper struct {
// Used to check row size.
maxRowSizeLog, maxRowSizeErr uint32
internal bool
metrics *Metrics
metrics *rowinfra.Metrics
}

func newRowHelper(
Expand All @@ -118,7 +119,7 @@ func newRowHelper(
indexes []catalog.Index,
sv *settings.Values,
internal bool,
metrics *Metrics,
metrics *rowinfra.Metrics,
) rowHelper {
rh := rowHelper{
Codec: codec,
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/row/inserter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc/valueside"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -51,7 +52,7 @@ func MakeInserter(
alloc *tree.DatumAlloc,
sv *settings.Values,
internal bool,
metrics *Metrics,
metrics *rowinfra.Metrics,
) (Inserter, error) {
ri := Inserter{
Helper: newRowHelper(
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/row/row_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/schemaexpr"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/transform"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
Expand Down Expand Up @@ -294,7 +295,7 @@ func NewDatumRowConverter(
evalCtx *tree.EvalContext,
kvCh chan<- KVBatch,
seqChunkProvider *SeqChunkProvider,
metrics *Metrics,
metrics *rowinfra.Metrics,
) (*DatumRowConverter, error) {
c := &DatumRowConverter{
tableDesc: tableDesc,
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/row/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc/valueside"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/unique"
Expand Down Expand Up @@ -87,7 +88,7 @@ func MakeUpdater(
alloc *tree.DatumAlloc,
sv *settings.Values,
internal bool,
metrics *Metrics,
metrics *rowinfra.Metrics,
) (Updater, error) {
if requestedCols == nil {
return Updater{}, errors.AssertionFailedf("requestedCols is nil in MakeUpdater")
Expand Down
6 changes: 5 additions & 1 deletion pkg/sql/rowinfra/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "rowinfra",
srcs = ["base.go"],
srcs = [
"base.go",
"metrics.go",
],
importpath = "github.com/cockroachdb/cockroach/pkg/sql/rowinfra",
visibility = ["//visibility:public"],
deps = ["//pkg/util/metric"],
)
2 changes: 1 addition & 1 deletion pkg/sql/row/metrics.go → pkg/sql/rowinfra/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package row
package rowinfra

import "github.com/cockroachdb/cockroach/pkg/util/metric"

Expand Down

0 comments on commit 060fe6a

Please sign in to comment.