Skip to content

Commit

Permalink
(sorter/cdc): disable block cache by default (#8982)
Browse files Browse the repository at this point in the history
close #8974
  • Loading branch information
hicqu authored May 19, 2023
1 parent 1fd9889 commit 30ab8ae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions cdc/processor/sourcemanager/engine/pebble/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,14 @@ func buildPebbleOption(cfg *config.DBConfig) (opts *pebble.Options) {
l.IndexBlockSize = 256 << 10 // 256 KB
l.FilterPolicy = bloom.FilterPolicy(10)
l.FilterType = pebble.TableFilter
if i == 0 {
l.TargetFileSize = 8 << 20 // 8 MB
} else if i < 4 {
l.TargetFileSize = opts.Levels[i-1].TargetFileSize * 2
// 8M is large enough because generally Sorter won't carry too much data.
// Avoiding large targe file is helpful to reduce write-amplification.
l.TargetFileSize = 8 << 20 // 8 MB
switch cfg.Compression {
case "none":
l.Compression = pebble.NoCompression
case "snappy":
l.Compression = pebble.SnappyCompression
}
l.EnsureDefaults()
}
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 @@ -92,7 +92,7 @@ const (
"owner-flush-interval": 50000000,
"processor-flush-interval": 50000000,
"sorter": {
"max-memory-percentage": 10,
"max-memory-percentage": 0,
"sort-dir": "/tmp/sorter",
"max-memory-consumption": 0,
"num-workerpool-goroutine": 0,
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ var defaultServerConfig = &ServerConfig{
OwnerFlushInterval: TomlDuration(50 * time.Millisecond),
ProcessorFlushInterval: TomlDuration(50 * time.Millisecond),
Sorter: &SorterConfig{
MaxMemoryPercentage: 10, // 10% is safe on machines with memory capacity <= 16GB
// Disable block-cache by default. TiCDC only scans events instead of
// accessing them randomly, so block-cache is unnecessary.
MaxMemoryPercentage: 0,
SortDir: DefaultSortDir,
},
Security: &SecurityConfig{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type SorterConfig struct {

// ValidateAndAdjust validates and adjusts the sorter configuration
func (c *SorterConfig) ValidateAndAdjust() error {
if c.MaxMemoryPercentage <= 0 || c.MaxMemoryPercentage > 80 {
if c.MaxMemoryPercentage < 0 || c.MaxMemoryPercentage > 80 {
return errors.ErrIllegalSorterParameter.GenWithStackByArgs(
"max-memory-percentage should be a percentage and within (0, 80]")
}
Expand Down

0 comments on commit 30ab8ae

Please sign in to comment.