From f19422e1c7a7f5b74e60f9211c70cb70a69d2076 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 11 Dec 2024 17:53:29 +0800 Subject: [PATCH] cmd/utils: relinquish GC cache to read cache in archive mode (#18991) --- cmd/utils/flags.go | 2 +- common/size.go | 16 ++++++++-------- common/size_test.go | 4 ++-- core/blockchain.go | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d244803b84..9c25f50df4 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -298,7 +298,7 @@ var ( CacheGCFlag = &cli.IntFlag{ Name: "cache-gc", Aliases: []string{"cache.gc"}, - Usage: "Percentage of cache memory allowance to use for trie pruning", + Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)", Value: 25, Category: flags.PerfCategory, } diff --git a/common/size.go b/common/size.go index bd0fc85c7d..6381499a48 100644 --- a/common/size.go +++ b/common/size.go @@ -26,10 +26,10 @@ type StorageSize float64 // String implements the stringer interface. func (s StorageSize) String() string { - if s > 1000000 { - return fmt.Sprintf("%.2f mB", s/1000000) - } else if s > 1000 { - return fmt.Sprintf("%.2f kB", s/1000) + if s > 1048576 { + return fmt.Sprintf("%.2f MiB", s/1048576) + } else if s > 1024 { + return fmt.Sprintf("%.2f KiB", s/1024) } else { return fmt.Sprintf("%.2f B", s) } @@ -38,10 +38,10 @@ func (s StorageSize) String() string { // TerminalString implements log.TerminalStringer, formatting a string for console // output during logging. func (s StorageSize) TerminalString() string { - if s > 1000000 { - return fmt.Sprintf("%.2fmB", s/1000000) - } else if s > 1000 { - return fmt.Sprintf("%.2fkB", s/1000) + if s > 1048576 { + return fmt.Sprintf("%.2fMiB", s/1048576) + } else if s > 1024 { + return fmt.Sprintf("%.2fKiB", s/1024) } else { return fmt.Sprintf("%.2fB", s) } diff --git a/common/size_test.go b/common/size_test.go index f5b6c725e2..0938d483c4 100644 --- a/common/size_test.go +++ b/common/size_test.go @@ -25,8 +25,8 @@ func TestStorageSizeString(t *testing.T) { size StorageSize str string }{ - {2381273, "2.38 mB"}, - {2192, "2.19 kB"}, + {2381273, "2.27 MiB"}, + {2192, "2.14 KiB"}, {12, "12.00 B"}, } diff --git a/core/blockchain.go b/core/blockchain.go index 6c75b759aa..3c74fc6f8e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2123,7 +2123,7 @@ const statsReportLimit = 8 * time.Second // report prints statistics if some number of blocks have been processed // or more than a few seconds have passed since the last message. -func (st *insertStats) report(chain []*types.Block, index int, cache common.StorageSize) { +func (st *insertStats) report(chain []*types.Block, index int, dirty common.StorageSize) { // Fetch the timings for the batch var ( now = mclock.Now() @@ -2138,7 +2138,7 @@ func (st *insertStats) report(chain []*types.Block, index int, cache common.Stor context := []interface{}{ "blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000, "elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed), - "number", end.Number(), "hash", end.Hash(), "cache", cache, + "number", end.Number(), "hash", end.Hash(), "dirty", dirty, } if st.queued > 0 { context = append(context, []interface{}{"queued", st.queued}...)