Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ var (
utils.CachePreimagesFlag,
utils.CacheLogSizeFlag,
utils.FDLimitFlag,
utils.MemoryLimitFlag,
utils.CryptoKZGFlag,
utils.ListenPortFlag,
utils.DiscoveryPortFlag,
Expand Down
16 changes: 11 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
Loading