Skip to content

Commit 96c3860

Browse files
authored
perf: tune async batch iterator (#3358)
1 parent 30af212 commit 96c3860

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

pkg/iter/batch_async.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type batch[T any] struct {
1919
done chan struct{}
2020
}
2121

22-
const minBatchSize = 64
22+
const minBatchSize = 2
2323

2424
func NewAsyncBatchIterator[T, N any](
2525
iterator Iterator[T],

pkg/phlaredb/query/repeated.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ type repeatedRowIterator[T any] struct {
2828
}
2929

3030
const (
31-
// Batch size specifies how many rows to be read
32-
// from a column at once. Note that the batched rows
33-
// are buffered in-memory, but not reference pages
34-
// they were read from.
35-
defaultRepeatedRowIteratorBatchSize = 32
36-
3731
// The value specifies how many individual values to be
3832
// read (decoded) from the page.
3933
//
@@ -57,8 +51,14 @@ func NewRepeatedRowIterator[T any](
5751
rows: rows,
5852
columns: NewMultiColumnIterator(ctx,
5953
WrapWithRowNumber(rowNumbers),
60-
defaultRepeatedRowIteratorBatchSize,
61-
rowGroups, columns...),
54+
// Batch size specifies how many rows to be read
55+
// from a column at once. Note that the batched rows
56+
// are buffered in-memory, but not reference pages
57+
// they were read from.
58+
4,
59+
rowGroups,
60+
columns...,
61+
),
6262
}
6363
}
6464

pkg/phlaredb/query/util.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package query
22

33
import (
4+
"slices"
45
"strings"
56

67
"github.com/colega/zeropool"
@@ -86,9 +87,7 @@ var parquetValuesPool = zeropool.New(func() []parquet.Value { return nil })
8687

8788
func CloneParquetValues(values []parquet.Value) []parquet.Value {
8889
p := parquetValuesPool.Get()
89-
if l := len(values); cap(p) < l {
90-
p = make([]parquet.Value, 0, 2*l)
91-
}
90+
p = slices.Grow(p, len(values))
9291
p = p[:len(values)]
9392
for i, v := range values {
9493
p[i] = v.Clone()

0 commit comments

Comments
 (0)