mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
cmd/utils: tune GOGC for large cache values (#34851)
--------- Co-authored-by: jonny rhea <5555162+jrhea@users.noreply.github.com>
This commit is contained in:
parent
d5d936d76c
commit
c3f2851872
2 changed files with 12 additions and 5 deletions
|
|
@ -101,6 +101,7 @@ var (
|
|||
utils.CachePreimagesFlag,
|
||||
utils.CacheLogSizeFlag,
|
||||
utils.FDLimitFlag,
|
||||
utils.MemoryLimitFlag,
|
||||
utils.CryptoKZGFlag,
|
||||
utils.ListenPortFlag,
|
||||
utils.DiscoveryPortFlag,
|
||||
|
|
|
|||
|
|
@ -554,6 +554,11 @@ var (
|
|||
Usage: "Raise the open file descriptor resource limit (default = system fd limit)",
|
||||
Category: flags.PerfCategory,
|
||||
}
|
||||
MemoryLimitFlag = &cli.IntFlag{
|
||||
Name: "memorylimit",
|
||||
Usage: "Soft memory limit for the Go runtime in megabytes (default = no limit)",
|
||||
Category: flags.PerfCategory,
|
||||
}
|
||||
CryptoKZGFlag = &cli.StringFlag{
|
||||
Name: "crypto.kzg",
|
||||
Usage: "KZG library implementation to use; gokzg (recommended) or ckzg",
|
||||
|
|
@ -1762,12 +1767,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
ctx.Set(CacheFlag.Name, strconv.Itoa(allowance))
|
||||
}
|
||||
}
|
||||
// Ensure Go's GC ignores the database cache for trigger percentage
|
||||
cache := ctx.Int(CacheFlag.Name)
|
||||
gogc := max(20, min(100, 100/(float64(cache)/1024)))
|
||||
|
||||
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
||||
godebug.SetGCPercent(int(gogc))
|
||||
godebug.SetGCPercent(100)
|
||||
if ctx.IsSet(MemoryLimitFlag.Name) {
|
||||
memLimit := int64(ctx.Int(MemoryLimitFlag.Name)) * 1024 * 1024
|
||||
log.Debug("Setting Go memory limit", "MB", memLimit/1024/1024)
|
||||
godebug.SetMemoryLimit(memLimit)
|
||||
}
|
||||
|
||||
if ctx.IsSet(SyncTargetFlag.Name) {
|
||||
cfg.SyncMode = ethconfig.FullSync // dev sync target forces full sync
|
||||
|
|
|
|||
Loading…
Reference in a new issue