Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 43c96b0

Browse files
authored
Merge pull request #213 from grafana/20220908_raise-buffer-capacity
Raise limits of buffer sizes
2 parents f895bb3 + 2724e0d commit 43c96b0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/firedb/deduplicating_slice.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ func (s *deduplicatingSlice[M, K, H, P]) Close() error {
7272
return nil
7373
}
7474

75-
const maxRowGroupBytes = 128 * 1024 * 1024
75+
const (
76+
maxBufferRowCount = 100_000 // 2 ^ 16
77+
maxRowGroupBytes = 128 * 1024 * 1024
78+
)
7679

7780
func (s *deduplicatingSlice[M, K, H, P]) maxRowsPerRowGroup() int {
7881
var (
@@ -96,7 +99,11 @@ func (s *deduplicatingSlice[M, K, H, P]) Flush() (numRows uint64, numRowGroups u
9699

97100
// intialise buffer if not existing
98101
if s.buffer == nil {
99-
s.buffer = parquet.NewBuffer(s.persister.Schema(), s.persister.SortingColumns())
102+
s.buffer = parquet.NewBuffer(
103+
s.persister.Schema(),
104+
s.persister.SortingColumns(),
105+
parquet.ColumnBufferCapacity(maxBufferRowCount),
106+
)
100107
}
101108

102109
var (
@@ -114,10 +121,14 @@ func (s *deduplicatingSlice[M, K, H, P]) Flush() (numRows uint64, numRowGroups u
114121
break
115122
}
116123

117-
// cap max row size
124+
// cap max row size by bytes
118125
if rowsToFlush > maxRows {
119126
rowsToFlush = maxRows
120127
}
128+
// cap max row size by buffer
129+
if rowsToFlush > maxBufferRowCount {
130+
rowsToFlush = maxBufferRowCount
131+
}
121132

122133
rows := make([]parquet.Row, rowsToFlush)
123134
var slicePos int

0 commit comments

Comments
 (0)