Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(storage/bloom/v1): bind bloom page size to max bloom size #14372

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading