ethdb/pebble: adjust the number of memory tables

This commit is contained in:
Gary Rong 2025-06-05 12:46:59 +08:00
parent 23f07d8c93
commit 3c41c1829c

View file

@ -199,9 +199,12 @@ func New(file string, cache int, handles int, namespace string, readonly bool) (
// Taken from https://github.com/cockroachdb/pebble/blob/master/internal/constants/constants.go
maxMemTableSize := (1<<31)<<(^uint(0)>>63) - 1
// Two memory tables is configured which is identical to leveldb,
// including a frozen memory table and another live one.
memTableLimit := 2
// Four memory tables are configured, each with a default size of 256 MB.
// Having multiple smaller memory tables while keeping the total memory
// limit unchanged allows writes to be flushed more smoothly. This helps
// avoid compaction spikes and mitigates write stalls caused by heavy
// compaction workloads.
memTableLimit := 4
memTableSize := cache * 1024 * 1024 / 2 / memTableLimit
// The memory table size is currently capped at maxMemTableSize-1 due to a