Skip to content

Commit

Permalink
Merge branch 'main' into skiprange-6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental committed Oct 3, 2024
2 parents f2023c0 + e9efcb5 commit 2e2628d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/storage/bloom/v1/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,25 @@ func NewBlockOptions(enc compression.Codec, maxBlockSizeBytes, maxBloomSizeBytes
opts := NewBlockOptionsFromSchema(Schema{
version: CurrentSchemaVersion,
encoding: enc,
})
}, maxBloomSizeBytes)
opts.BlockSize = maxBlockSizeBytes
opts.UnencodedBlockOptions.MaxBloomSizeBytes = maxBloomSizeBytes
return opts
}

func NewBlockOptionsFromSchema(s Schema) BlockOptions {
func NewBlockOptionsFromSchema(s Schema, maxBloomSizeBytes uint64) BlockOptions {
return BlockOptions{
Schema: s,
// TODO(owen-d): benchmark and find good defaults
SeriesPageSize: 4 << 10, // 4KB, typical page size
BloomPageSize: 256 << 10, // 256KB, no idea what to make this
SeriesPageSize: 4 << 10, // 4KB, typical page size

// Allow one bloom page to fit either several small blooms or one large
// bloom at max size.
//
// Previously this value was fixed at 256KB, which is smaller than most
// blooms. Setting this value less than maxBloomSizeBytes means that most
// pages will consist of a single oversized bloom.
BloomPageSize: maxBloomSizeBytes,
}
}

Expand Down
16 changes: 16 additions & 0 deletions pkg/storage/bloom/v1/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ var blockEncodings = []compression.Codec{
compression.Zstd,
}

func TestBlockOptions_BloomPageSize(t *testing.T) {
t.Parallel()

var (
maxBlockSizeBytes = uint64(50 << 10)
maxBloomSizeBytes = uint64(10 << 10)
)

opts := NewBlockOptions(compression.None, maxBlockSizeBytes, maxBloomSizeBytes)

require.GreaterOrEqual(
t, opts.BloomPageSize, maxBloomSizeBytes,
"opts.BloomPageSize should be greater or equal to the maximum bloom size to avoid having too many overfilled pages",
)
}

func TestBlockOptions_RoundTrip(t *testing.T) {
t.Parallel()
opts := BlockOptions{
Expand Down

0 comments on commit 2e2628d

Please sign in to comment.