From 3c41c1829cf6d07d2a309e453aa403bc71ec0989 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Thu, 5 Jun 2025 12:46:59 +0800 Subject: [PATCH] ethdb/pebble: adjust the number of memory tables --- ethdb/pebble/pebble.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index 5c851af910..aa9eca9c92 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -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