Skip to content

Commit

Permalink
This is an automated cherry-pick of #11099
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
hicqu authored and ti-chi-bot committed May 17, 2024
1 parent 687dea0 commit b2b7e38
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cdc/processor/sourcemanager/engine/pebble/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ func buildPebbleOption(cfg *config.DBConfig) (opts *pebble.Options) {
opts.ErrorIfExists = true
opts.DisableWAL = false // Delete range requires WAL.
opts.MaxOpenFiles = cfg.MaxOpenFiles / cfg.Count
<<<<<<< HEAD:cdc/processor/sourcemanager/engine/pebble/db.go
opts.MaxConcurrentCompactions = 6
opts.L0CompactionThreshold = cfg.CompactionL0Trigger
=======
opts.MaxConcurrentCompactions = func() int { return 6 }
opts.L0CompactionThreshold = 4 // Default for PebbleDB.
opts.L0CompactionFileThreshold = cfg.CompactionL0Trigger
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099)):cdc/processor/sourcemanager/sorter/pebble/db.go
opts.L0StopWritesThreshold = cfg.WriteL0PauseTrigger
opts.LBaseMaxBytes = 64 << 20 // 64 MB
opts.MemTableSize = cfg.WriterBufferSize
Expand Down
30 changes: 30 additions & 0 deletions pkg/cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func TestParseCfg(t *testing.T) {
},
Debug: &config.DebugConfig{
DB: &config.DBConfig{
<<<<<<< HEAD
Count: 8,
Concurrency: 128,
MaxOpenFiles: 10000,
Expand All @@ -180,6 +181,15 @@ func TestParseCfg(t *testing.T) {
CompactionPeriod: 1800,
IteratorMaxAliveDuration: 10000,
IteratorSlowReadDuration: 256,
=======
Count: 8,
MaxOpenFiles: 10000,
BlockSize: 65536,
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 16,
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
Expand Down Expand Up @@ -458,6 +468,7 @@ cert-allowed-cn = ["dd","ee"]
},
Debug: &config.DebugConfig{
DB: &config.DBConfig{
<<<<<<< HEAD
Count: 8,
Concurrency: 128,
MaxOpenFiles: 10000,
Expand All @@ -470,6 +481,15 @@ cert-allowed-cn = ["dd","ee"]
CompactionPeriod: 1800,
IteratorMaxAliveDuration: 10000,
IteratorSlowReadDuration: 256,
=======
Count: 8,
MaxOpenFiles: 10000,
BlockSize: 65536,
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 16,
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
Expand Down Expand Up @@ -525,6 +545,7 @@ unknown3 = 3
require.Nil(t, err)
require.Equal(t, &config.DebugConfig{
DB: &config.DBConfig{
<<<<<<< HEAD
Count: 8,
Concurrency: 128,
MaxOpenFiles: 10000,
Expand All @@ -537,6 +558,15 @@ unknown3 = 3
CompactionPeriod: 1800,
IteratorMaxAliveDuration: 10000,
IteratorSlowReadDuration: 256,
=======
Count: 8,
MaxOpenFiles: 10000,
BlockSize: 65536,
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 16,
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))
},
// We expect the default configuration here.
Messages: &config.MessagesConfig{
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/config_test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ const (
"writer-buffer-size": 8388608,
"compression": "snappy",
"write-l0-pause-trigger": 2147483647,
<<<<<<< HEAD
"compaction-l0-trigger": 160,
"compaction-deletion-threshold": 10485760,
"compaction-period": 1800,
"iterator-max-alive-duration": 10000,
"iterator-slow-read-duration": 256
=======
"compaction-l0-trigger": 16
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))
},
"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 @@ -51,7 +51,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"`
// CompactionDeletionThreshold defines the threshold of the number of deletion that
// trigger compaction.
Expand Down
9 changes: 9 additions & 0 deletions pkg/config/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ var defaultServerConfig = &ServerConfig{
Count: 8,
// Following configs are optimized for write/read throughput.
// Users should not change them.
<<<<<<< HEAD
Concurrency: 128,
MaxOpenFiles: 10000,
BlockSize: 65536,
Expand All @@ -135,6 +136,14 @@ var defaultServerConfig = &ServerConfig{
CompactionPeriod: 1800,
IteratorMaxAliveDuration: 10000,
IteratorSlowReadDuration: 256,
=======
MaxOpenFiles: 10000,
BlockSize: 65536,
WriterBufferSize: 8388608,
Compression: "snappy",
WriteL0PauseTrigger: math.MaxInt32,
CompactionL0Trigger: 16, // Based on a performance test on 4K tables.
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))
},
Messages: defaultMessageConfig.Clone(),

Expand Down
17 changes: 17 additions & 0 deletions pkg/spanz/hash_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
package spanz

import (
<<<<<<< HEAD

Check failure on line 17 in pkg/spanz/hash_map.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

missing import path

Check failure on line 17 in pkg/spanz/hash_map.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

missing import path
=======
"encoding/binary"

"blainsmith.com/go/seahash"
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))
"github.com/pingcap/tiflow/cdc/processor/tablepb"
)

Expand Down Expand Up @@ -74,3 +80,14 @@ func (m *HashMap[T]) Range(iterator ItemIterator[T]) {
}
}
}
<<<<<<< HEAD
=======

// HashTableSpan hashes the given span to a slot offset.
func HashTableSpan(span tablepb.Span, slots int) int {
b := make([]byte, 8+len(span.StartKey))
binary.LittleEndian.PutUint64(b[0:8], uint64(span.TableID))
copy(b[8:], span.StartKey)
return int(seahash.Sum64(b) % uint64(slots))
}
>>>>>>> 08aec53320 (cdc: adjust sorter options to avoid Seek CPU usage exploding (#11099))

0 comments on commit b2b7e38

Please sign in to comment.