diff --git a/cdc/processor/sourcemanager/engine/pebble/db.go b/cdc/processor/sourcemanager/engine/pebble/db.go index 3c48ff1aa07..b299ecbd8e0 100644 --- a/cdc/processor/sourcemanager/engine/pebble/db.go +++ b/cdc/processor/sourcemanager/engine/pebble/db.go @@ -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() } diff --git a/pkg/config/config_test_data.go b/pkg/config/config_test_data.go index d12ad516186..eaebc731cb9 100644 --- a/pkg/config/config_test_data.go +++ b/pkg/config/config_test_data.go @@ -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, diff --git a/pkg/config/server_config.go b/pkg/config/server_config.go index a2416cf855c..f1e1819d8bc 100644 --- a/pkg/config/server_config.go +++ b/pkg/config/server_config.go @@ -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{}, diff --git a/pkg/config/sorter.go b/pkg/config/sorter.go index 058b269459d..8ec1ede0dab 100644 --- a/pkg/config/sorter.go +++ b/pkg/config/sorter.go @@ -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]") }