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

TBS: update pebble options for performance #15664

Merged
merged 5 commits into from
Feb 12, 2025
Merged
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
9 changes: 5 additions & 4 deletions x-pack/apm-server/sampling/eventstorage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,35 @@ func eventComparer() *pebble.Comparer {
}
return comparer.ComparePointSuffixes(a[ap:], b[bp:])
}
comparer.Name = "apmserver.EventComparer"
comparer.Name = "apmserver.EventComparer" // this should stay constant, otherwise existing database won't open
return &comparer
}

func OpenEventPebble(storageDir string) (*pebble.DB, error) {
// Option values are picked and validated in https://github.com/elastic/apm-server/issues/15568
opts := &pebble.Options{
FormatMajorVersion: pebble.FormatColumnarBlocks,
Logger: logp.NewLogger(logs.Sampling),
MemTableSize: 16 << 20,
Levels: []pebble.LevelOptions{
{
BlockSize: 16 << 10,
BlockSize: 32 << 10, // the bigger the blocks, the better the compression and the smaller the index block
Compression: func() pebble.Compression { return pebble.SnappyCompression },
FilterPolicy: bloom.FilterPolicy(10),
FilterType: pebble.TableFilter,
},
},
Comparer: eventComparer(),
}
opts.Experimental.MaxWriterConcurrency = 1 // >0 enables parallel writers, the actual value doesn't matter
return pebble.Open(filepath.Join(storageDir, "event"), opts)
}

func OpenDecisionPebble(storageDir string) (*pebble.DB, error) {
// Option values are picked and validated in https://github.com/elastic/apm-server/issues/15568
return pebble.Open(filepath.Join(storageDir, "decision"), &pebble.Options{
FormatMajorVersion: pebble.FormatColumnarBlocks,
Logger: logp.NewLogger(logs.Sampling),
MemTableSize: 2 << 20,
MemTableSize: 2 << 20, // big memtables are slow to scan, and significantly slow the hot path
Levels: []pebble.LevelOptions{
{
BlockSize: 2 << 10,
Expand Down