option to disable runtime.ReadMemStats (#457)

* save

* save

* save

* save
This commit is contained in:
Alex Sharov 2022-05-19 11:46:55 +07:00 committed by GitHub
parent e304418d5a
commit a8ce14e8cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 13 deletions

21
common/experiments.go Normal file
View File

@ -0,0 +1,21 @@
package common
import (
"os"
"runtime"
)
var doMemstat = true
func init() {
_, ok := os.LookupEnv("NO_MEMSTAT")
if ok {
doMemstat = false
}
}
func ReadMemStats(m *runtime.MemStats) {
if doMemstat {
runtime.ReadMemStats(m)
}
}

View File

@ -400,7 +400,9 @@ func reducedict(ctx context.Context, trace bool, logPrefix, segmentFilePath stri
default:
case <-logEvery.C:
var m runtime.MemStats
runtime.ReadMemStats(&m)
if lvl >= log.LvlInfo {
common.ReadMemStats(&m)
}
log.Log(lvl, fmt.Sprintf("[%s] Replacement preprocessing", logPrefix),
"processed", fmt.Sprintf("%.2f%%", 100*float64(outCount)/float64(datFile.count)),
//"input", common.ByteCount(inputSize.Load()), "output", common.ByteCount(outputSize.Load()),
@ -448,7 +450,7 @@ func reducedict(ctx context.Context, trace bool, logPrefix, segmentFilePath stri
}
//var m runtime.MemStats
//runtime.ReadMemStats(&m)
//common.ReadMemStats(&m)
//log.Info(fmt.Sprintf("[%s] Dictionary build done", logPrefix), "input", common.ByteCount(inputSize.Load()), "output", common.ByteCount(outputSize.Load()), "alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys))
posMap := make(map[uint64]uint64)
for _, m := range posMaps {

View File

@ -222,7 +222,7 @@ func loadFilesIntoBucket(logPrefix string, db kv.RwTx, bucket string, bufType in
logArs = append(logArs, "current key", makeCurrentKeyStr(k))
}
runtime.ReadMemStats(&m)
common.ReadMemStats(&m)
logArs = append(logArs, "alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys))
log.Info(fmt.Sprintf("[%s] ETL [2/2] Loading", logPrefix), logArs...)
}
@ -273,12 +273,7 @@ func loadFilesIntoBucket(logPrefix string, db kv.RwTx, bucket string, bufType in
}
}
runtime.ReadMemStats(&m)
log.Trace(
fmt.Sprintf("[%s] ETL Load done", logPrefix),
"bucket", bucket,
"records", i,
"alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys))
log.Trace(fmt.Sprintf("[%s] ETL Load done", logPrefix), "bucket", bucket, "records", i)
return nil
}

View File

@ -67,7 +67,9 @@ func FlushToDisk(b Buffer, tmpdir string, doFsync bool, lvl log.Lvl) (dataProvid
defer func() {
b.Reset() // run it after buf.flush and file.sync
var m runtime.MemStats
runtime.ReadMemStats(&m)
if lvl >= log.LvlInfo {
common.ReadMemStats(&m)
}
log.Log(lvl,
"Flushed buffer file",
"name", bufferFile.Name(),

View File

@ -143,7 +143,7 @@ func extractBucketIntoFiles(
logArs = append(logArs, "current key", makeCurrentKeyStr(k))
}
runtime.ReadMemStats(&m)
common.ReadMemStats(&m)
logArs = append(logArs, "alloc", common.ByteCount(m.Alloc), "sys", common.ByteCount(m.Sys))
log.Info(fmt.Sprintf("[%s] ETL [1/2] Extracting", logPrefix), logArs...)
}

View File

@ -1676,8 +1676,7 @@ func (p *TxPool) logStats() {
//idsInMem := p.senders.idsCount()
var m runtime.MemStats
runtime.ReadMemStats(&m)
common.ReadMemStats(&m)
ctx := []interface{}{
//"baseFee", fmt.Sprintf("%d, %dm", protocolBaseFee, pendingBaseFee/1_000_000),
"block", p.lastSeenBlock.Load(),