From 2bab3281b7ecd76b95bb64bb6f06528416c6b628 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Tue, 14 Feb 2023 14:09:36 -0800 Subject: [PATCH 1/3] fix incorrect config --- ethdb/pebble/pebble.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index fa27efd9634..31f33e00981 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -125,7 +125,13 @@ func New(file string, cache int, handles int, namespace string, readonly bool) ( handles = minHandles } logger := log.New("database", file) - logger.Info("Allocated cache and file handles", "cache", common.StorageSize(cache*1024*1024), "handles", handles) + logger.Info( + "Allocated cache and file handles", + "cache", + common.StorageSize(cache*1024*1024), + "handles", + handles, + ) // The max memtable size is limited by the uint32 offsets stored in // internal/arenaskl.node, DeferredBatchOp, and flushableBatchEntry. @@ -157,7 +163,10 @@ func New(file string, cache int, handles int, namespace string, readonly bool) ( // MemTableStopWritesThreshold places a hard limit on the size // of the existent MemTables(including the frozen one). - MemTableStopWritesThreshold: memTableLimit * memTableSize, + // Note, this must be the number of tables not the size of all memtables + // according to https://github.com/cockroachdb/pebble/blob/master/options.go#L738-L742 + // and to https://github.com/cockroachdb/pebble/blob/master/db.go#L1892-L1903. + MemTableStopWritesThreshold: memTableLimit, // The default compaction concurrency(1 thread), // Here use all available CPUs for faster compaction. @@ -440,7 +449,11 @@ func (d *Database) meter(refresh time.Duration) { d.diskWriteMeter.Mark(nWrites[i%2] - nWrites[(i-1)%2]) } // See https://github.com/cockroachdb/pebble/pull/1628#pullrequestreview-1026664054 - manuallyAllocated := metrics.BlockCache.Size + int64(metrics.MemTable.Size) + int64(metrics.MemTable.ZombieSize) + manuallyAllocated := metrics.BlockCache.Size + int64( + metrics.MemTable.Size, + ) + int64( + metrics.MemTable.ZombieSize, + ) d.manualMemAllocGauge.Update(manuallyAllocated) d.memCompGauge.Update(metrics.Flush.Count) d.nonlevel0CompGauge.Update(nonLevel0CompCount) From f14091c6a5c7e7dc9c5499a1021ab52f184ab626 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Tue, 14 Feb 2023 14:10:53 -0800 Subject: [PATCH 2/3] revert newline change --- ethdb/pebble/pebble.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index 31f33e00981..7b2dd1e2cc8 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -449,11 +449,7 @@ func (d *Database) meter(refresh time.Duration) { d.diskWriteMeter.Mark(nWrites[i%2] - nWrites[(i-1)%2]) } // See https://github.com/cockroachdb/pebble/pull/1628#pullrequestreview-1026664054 - manuallyAllocated := metrics.BlockCache.Size + int64( - metrics.MemTable.Size, - ) + int64( - metrics.MemTable.ZombieSize, - ) + manuallyAllocated := metrics.BlockCache.Size + int64(metrics.MemTable.Size) + int64(metrics.MemTable.ZombieSize) d.manualMemAllocGauge.Update(manuallyAllocated) d.memCompGauge.Update(metrics.Flush.Count) d.nonlevel0CompGauge.Update(nonLevel0CompCount) From 6657f2e84486009b6cfa35d5c785d8267d45fe48 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Tue, 14 Feb 2023 23:13:53 -0800 Subject: [PATCH 3/3] revert linter changes --- ethdb/pebble/pebble.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index 7b2dd1e2cc8..fdad13b392e 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -125,13 +125,7 @@ func New(file string, cache int, handles int, namespace string, readonly bool) ( handles = minHandles } logger := log.New("database", file) - logger.Info( - "Allocated cache and file handles", - "cache", - common.StorageSize(cache*1024*1024), - "handles", - handles, - ) + logger.Info("Allocated cache and file handles", "cache", common.StorageSize(cache*1024*1024), "handles", handles) // The max memtable size is limited by the uint32 offsets stored in // internal/arenaskl.node, DeferredBatchOp, and flushableBatchEntry.