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

cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099) #11135

Merged
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
3 changes: 2 additions & 1 deletion cdc/processor/sourcemanager/sorter/pebble/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func buildPebbleOption(cfg *config.DBConfig) (opts *pebble.Options) {
opts.DisableWAL = false // Delete range requires WAL.
opts.MaxOpenFiles = cfg.MaxOpenFiles / cfg.Count
opts.MaxConcurrentCompactions = func() int { return 6 }
opts.L0CompactionThreshold = cfg.CompactionL0Trigger
opts.L0CompactionThreshold = 4 // Default for PebbleDB.
opts.L0CompactionFileThreshold = cfg.CompactionL0Trigger
opts.L0StopWritesThreshold = cfg.WriteL0PauseTrigger
opts.LBaseMaxBytes = 64 << 20 // 64 MB
opts.MemTableSize = uint64(cfg.WriterBufferSize)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func TestParseCfg(t *testing.T) {
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 160,
CompactionL0Trigger: 16,
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
Expand Down Expand Up @@ -464,7 +464,7 @@ cert-allowed-cn = ["dd","ee"]
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 160,
CompactionL0Trigger: 16,
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
Expand Down Expand Up @@ -529,7 +529,7 @@ unknown3 = 3
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 160,
CompactionL0Trigger: 16,
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const (
"writer-buffer-size": 8388608,
"compression": "snappy",
"write-l0-pause-trigger": 2147483647,
"compaction-l0-trigger": 160
"compaction-l0-trigger": 16
},
"messages": {
"client-max-batch-interval": 10000000,
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type DBConfig struct {
// CompactionL0Trigger defines number of db sst file at level-0 that will
// trigger compaction.
//
// The default value is 160.
// The default value is 16, which is based on a performance test on 4K tables.
CompactionL0Trigger int `toml:"compaction-l0-trigger" json:"compaction-l0-trigger"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var defaultServerConfig = &ServerConfig{
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 160,
CompactionL0Trigger: 16, // Based on a performance test on 4K tables.
},
Messages: defaultMessageConfig.Clone(),

Expand Down
6 changes: 2 additions & 4 deletions pkg/spanz/hash_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import (
"encoding/binary"
"hash/fnv"

"blainsmith.com/go/seahash"
"github.com/pingcap/tiflow/cdc/processor/tablepb"
)

Expand Down Expand Up @@ -80,10 +80,8 @@

// HashTableSpan hashes the given span to a slot offset.
func HashTableSpan(span tablepb.Span, slots int) int {
h := fnv.New64()
b := make([]byte, 8+len(span.StartKey))
binary.LittleEndian.PutUint64(b[0:8], uint64(span.TableID))
copy(b[8:], span.StartKey)
h.Write(b[:])
return int(h.Sum64() % uint64(slots))
return int(seahash.Sum64(b) % uint64(slots))

Check warning on line 86 in pkg/spanz/hash_map.go

View check run for this annotation

Codecov / codecov/patch

pkg/spanz/hash_map.go#L86

Added line #L86 was not covered by tests
}
Loading