Skip to content

High CPU from append: frequent runtime.growslice due to missing slice preallocation #1100

@danidr7

Description

@danidr7

Describe the bug

  • The Append built-in uses excessive CPU due to frequent runtime.growslice calls.
Image

Steps to reproduce

  1. Run an INSERT that writes a large number of rows.
  2. This triggers multiple append operations that allocate new underlying arrays because the current slice has no predefined capacity.
  3. Capture a Go CPU profile and inspect the hot spots for append and runtime.growslice.

Expected behavior

  • Provide a way to preallocate slice capacity (or otherwise reduce allocations) so that calls to runtime.growslice are minimized or eliminated.

Code example

  • The current column type does not allow setting the initial capacity of the slice:
type ColDateTime64 struct {
    Data         []DateTime64
    Location     *time.Location
    Precision    Precision
    PrecisionSet bool
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions