Skip to content

Commit

Permalink
colexec: reorder some fields to reduce memory footprint
Browse files Browse the repository at this point in the history
This commit applies some of the fixes found by the `fieldalignment` tool
on the colexec packages which reorder some fields in the structs so that
the memory footprint is reduced.

Release note: None
  • Loading branch information
yuzefovich committed Aug 8, 2022
1 parent 773332f commit e9c7cae
Show file tree
Hide file tree
Showing 20 changed files with 243 additions and 246 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/colexec/colexecargs/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func NewExprHelper() *ExprHelper {
// ExprHelper is a utility struct that helps with expression handling in the
// vectorized engine.
type ExprHelper struct {
helper execinfrapb.ExprHelper
SemaCtx *tree.SemaContext
helper execinfrapb.ExprHelper
}

// ProcessExpr processes the given expression and returns a well-typed
Expand Down
7 changes: 3 additions & 4 deletions pkg/sql/colexec/colexecbase/cast.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pkg/sql/colexec/colexecbase/cast_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,12 @@ func IsCastSupported(fromType, toType *types.T) bool {
}

type castOpBase struct {
colexecop.OneInputInitCloserHelper

allocator *colmem.Allocator
colIdx int
outputIdx int
evalCtx *eval.Context
buf bytes.Buffer
colexecop.OneInputInitCloserHelper
colIdx int
outputIdx int
}

func (c *castOpBase) Reset(ctx context.Context) {
Expand Down
44 changes: 22 additions & 22 deletions pkg/sql/colexec/colexecbase/distinct.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/sql/colexec/colexecbase/distinct_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ func newPartitioner(t *types.T, nullsAreDistinct bool) partitioner {
// true to the resultant bool column for every value that differs from the
// previous one.
type distinct_TYPEOp struct {
colexecop.OneInputHelper

// outputCol is the boolean output column. It is shared by all of the
// other distinct operators in a distinct operator set.
outputCol []bool
Expand All @@ -147,8 +149,6 @@ type distinct_TYPEOp struct {
// still works across batch boundaries.
lastVal _GOTYPE

colexecop.OneInputHelper

// distinctColIdx is the index of the column to distinct upon.
distinctColIdx int

Expand Down
5 changes: 2 additions & 3 deletions pkg/sql/colexec/colexecbase/simple_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import (
// simpleProjectOp is an operator that implements "simple projection" - removal of
// columns that aren't needed by later operators.
type simpleProjectOp struct {
colexecop.OneInputInitCloserHelper
colexecop.NonExplainable

batches map[coldata.Batch]*projectingBatch
colexecop.OneInputInitCloserHelper
projection []uint32
batches map[coldata.Batch]*projectingBatch
// numBatchesLoggingThreshold is the threshold on the number of items in
// 'batches' map at which we will log a message when a new projectingBatch
// is created. It is growing exponentially.
Expand Down
Loading

0 comments on commit e9c7cae

Please sign in to comment.