cmd/utils: relinquish GC cache to read cache in archive mode (#18991)

This commit is contained in:
Daniel Liu 2024-12-11 17:53:29 +08:00
parent 2772e096b4
commit f19422e1c7
4 changed files with 13 additions and 13 deletions

View file

@ -298,7 +298,7 @@ var (
CacheGCFlag = &cli.IntFlag{ CacheGCFlag = &cli.IntFlag{
Name: "cache-gc", Name: "cache-gc",
Aliases: []string{"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, Value: 25,
Category: flags.PerfCategory, Category: flags.PerfCategory,
} }

View file

@ -26,10 +26,10 @@ type StorageSize float64
// String implements the stringer interface. // String implements the stringer interface.
func (s StorageSize) String() string { func (s StorageSize) String() string {
if s > 1000000 { if s > 1048576 {
return fmt.Sprintf("%.2f mB", s/1000000) return fmt.Sprintf("%.2f MiB", s/1048576)
} else if s > 1000 { } else if s > 1024 {
return fmt.Sprintf("%.2f kB", s/1000) return fmt.Sprintf("%.2f KiB", s/1024)
} else { } else {
return fmt.Sprintf("%.2f B", s) return fmt.Sprintf("%.2f B", s)
} }
@ -38,10 +38,10 @@ func (s StorageSize) String() string {
// TerminalString implements log.TerminalStringer, formatting a string for console // TerminalString implements log.TerminalStringer, formatting a string for console
// output during logging. // output during logging.
func (s StorageSize) TerminalString() string { func (s StorageSize) TerminalString() string {
if s > 1000000 { if s > 1048576 {
return fmt.Sprintf("%.2fmB", s/1000000) return fmt.Sprintf("%.2fMiB", s/1048576)
} else if s > 1000 { } else if s > 1024 {
return fmt.Sprintf("%.2fkB", s/1000) return fmt.Sprintf("%.2fKiB", s/1024)
} else { } else {
return fmt.Sprintf("%.2fB", s) return fmt.Sprintf("%.2fB", s)
} }

View file

@ -25,8 +25,8 @@ func TestStorageSizeString(t *testing.T) {
size StorageSize size StorageSize
str string str string
}{ }{
{2381273, "2.38 mB"}, {2381273, "2.27 MiB"},
{2192, "2.19 kB"}, {2192, "2.14 KiB"},
{12, "12.00 B"}, {12, "12.00 B"},
} }

View file

@ -2123,7 +2123,7 @@ const statsReportLimit = 8 * time.Second
// report prints statistics if some number of blocks have been processed // report prints statistics if some number of blocks have been processed
// or more than a few seconds have passed since the last message. // 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 // Fetch the timings for the batch
var ( var (
now = mclock.Now() now = mclock.Now()
@ -2138,7 +2138,7 @@ func (st *insertStats) report(chain []*types.Block, index int, cache common.Stor
context := []interface{}{ context := []interface{}{
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000, "blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
"elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed), "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 { if st.queued > 0 {
context = append(context, []interface{}{"queued", st.queued}...) context = append(context, []interface{}{"queued", st.queued}...)