Skip to content

Chunk column reuse #28340

@tiancaiamao

Description

@tiancaiamao

Enhancement

Currently, TiDB allocation cause too much burden to the Go GC, and slow down the program.

Prepare plan cache can help a lot to reduce the allocation, unfortunately we still can not take full advantage of it.
I reported this issue #26868 in the past.
@qw4990 and @Reminiscent is handling it and we wish to make it GA soon.

Prepare plan cache ranks top1 in reducing the allocation.
So after that, I find chunk allocation also accounts a lot.

If we can reuse the chunk column, it may reduce the object allocation.

Chunk columns are feasible for reuse, as you can see they are fix sized depending on the field type, and there is no complex structure in it, only slice of bytes:

type Column struct {
length int
nullBitmap []byte // bit 0 is null, 1 is not null
offsets []int64 // used for varLen column. Row i starts from data[offsets[i]]
data []byte
elemBuf []byte
}
// NewColumn creates a new column with the specific type and capacity.
func NewColumn(ft *types.FieldType, cap int) *Column {
return newColumn(getFixedLen(ft), cap)
}
func newColumn(typeSize, cap int) *Column {
var col *Column
if typeSize == varElemLen {
col = newVarLenColumn(cap)
} else {
col = newFixedLenColumn(typeSize, cap)
}
return col
}

Metadata

Metadata

Assignees

Labels

type/enhancementThe issue or PR belongs to an enhancement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions