Skip to content

Commit

Permalink
perf: tune async batch iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnikovae committed Jun 17, 2024
1 parent 30af212 commit 5a279f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/iter/batch_async.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type batch[T any] struct {
done chan struct{}
}

const minBatchSize = 64
const minBatchSize = 2

func NewAsyncBatchIterator[T, N any](
iterator Iterator[T],
Expand Down
16 changes: 8 additions & 8 deletions pkg/phlaredb/query/repeated.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ type repeatedRowIterator[T any] struct {
}

const (
// Batch size specifies how many rows to be read
// from a column at once. Note that the batched rows
// are buffered in-memory, but not reference pages
// they were read from.
defaultRepeatedRowIteratorBatchSize = 32

// The value specifies how many individual values to be
// read (decoded) from the page.
//
Expand All @@ -57,8 +51,14 @@ func NewRepeatedRowIterator[T any](
rows: rows,
columns: NewMultiColumnIterator(ctx,
WrapWithRowNumber(rowNumbers),
defaultRepeatedRowIteratorBatchSize,
rowGroups, columns...),
// Batch size specifies how many rows to be read
// from a column at once. Note that the batched rows
// are buffered in-memory, but not reference pages
// they were read from.
4,
rowGroups,
columns...,
),
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/phlaredb/query/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var parquetValuesPool = zeropool.New(func() []parquet.Value { return nil })
func CloneParquetValues(values []parquet.Value) []parquet.Value {
p := parquetValuesPool.Get()
if l := len(values); cap(p) < l {
p = make([]parquet.Value, 0, 2*l)
p = make([]parquet.Value, 0, l)
}
p = p[:len(values)]
for i, v := range values {
Expand Down

0 comments on commit 5a279f5

Please sign in to comment.