Skip to content

Commit cea7b25

Browse files
authored
Increase parquet read buffer size (#2924)
1 parent 7007d52 commit cea7b25

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pkg/phlaredb/block_querier.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ import (
4949
)
5050

5151
const (
52-
defaultBatchSize = 4096
53-
parquetReadBufferSize = 256 << 10 // 256KB
52+
defaultBatchSize = 4096
53+
54+
// This controls the buffer size for reads to a parquet io.Reader. This value should be small for memory or
55+
// disk backed readers, but when the reader is backed by network storage a larger size will be advantageous.
56+
//
57+
// The chosen value should be larger than the page size. Page sizes depend on the write buffer size as well as
58+
// on how well the data is encoded. In practice, they tend to be around 1MB.
59+
parquetReadBufferSize = 2 << 20
5460
)
5561

5662
type tableReader interface {

pkg/phlaredb/profile_store.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import (
2626
"github.com/grafana/pyroscope/pkg/util/build"
2727
)
2828

29+
const (
30+
parquetWriteBufferSize = 3 << 20 // 3MB
31+
)
32+
2933
type profileStore struct {
3034
size atomic.Uint64
3135
totalSize atomic.Uint64
@@ -63,7 +67,7 @@ type profileStore struct {
6367
}
6468

6569
func newParquetProfileWriter(writer io.Writer, options ...parquet.WriterOption) *parquet.GenericWriter[*schemav1.Profile] {
66-
options = append(options, parquet.PageBufferSize(3*1024*1024))
70+
options = append(options, parquet.PageBufferSize(parquetWriteBufferSize))
6771
options = append(options, parquet.CreatedBy("github.com/grafana/pyroscope/", build.Version, build.Revision))
6872
options = append(options, schemav1.ProfilesSchema)
6973
return parquet.NewGenericWriter[*schemav1.Profile](

0 commit comments

Comments
 (0)