diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-04-12 17:06:43 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-04-12 17:06:43 +0800 |
commit | d9d60a5a7f622acd9233d075f009a91a84b62c78 (patch) | |
tree | 8e96ee16ec340f641e20099b584146edac263fc0 /cmd | |
parent | 4a4abc41d45915a6eb8376e569b14db84ad7328a (diff) | |
download | go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.tar go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.tar.gz go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.tar.bz2 go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.tar.lz go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.tar.xz go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.tar.zst go-tangerine-d9d60a5a7f622acd9233d075f009a91a84b62c78.zip |
cmd: special case default cache allowance (4GB mainnet, 128MB ligh)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/main.go | 14 | ||||
-rw-r--r-- | cmd/utils/flags.go | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 4f3849a41..c439e36fc 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -234,6 +234,20 @@ func init() { if err := debug.Setup(ctx, logdir); err != nil { return err } + // If we're a full node on mainnet without --cache specified, bump default cache allowance + if ctx.GlobalString(utils.SyncModeFlag.Name) != "light" && !ctx.GlobalIsSet(utils.CacheFlag.Name) && !ctx.GlobalIsSet(utils.NetworkIdFlag.Name) { + // Make sure we're not on any supported preconfigured testnet either + if !ctx.GlobalIsSet(utils.TestnetFlag.Name) && !ctx.GlobalIsSet(utils.RinkebyFlag.Name) && !ctx.GlobalIsSet(utils.GoerliFlag.Name) { + // Nope, we're really on mainnet. Bump that cache up! + log.Info("Bumping default cache on mainnet", "provided", ctx.GlobalInt(utils.CacheFlag.Name), "updated", 4096) + ctx.GlobalSet(utils.CacheFlag.Name, strconv.Itoa(4096)) + } + } + // If we're running a light client on any network, drop the cache to some meaningfully low amount + if ctx.GlobalString(utils.SyncModeFlag.Name) == "light" && !ctx.GlobalIsSet(utils.CacheFlag.Name) { + log.Info("Dropping default light client cache", "provided", ctx.GlobalInt(utils.CacheFlag.Name), "updated", 128) + ctx.GlobalSet(utils.CacheFlag.Name, strconv.Itoa(128)) + } // Cap the cache allowance and tune the garbage collector var mem gosigar.Mem if err := mem.Get(); err == nil { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index f5f4cde5b..689202c69 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -331,7 +331,7 @@ var ( // Performance tuning settings CacheFlag = cli.IntFlag{ Name: "cache", - Usage: "Megabytes of memory allocated to internal caching", + Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode)", Value: 1024, } CacheDatabaseFlag = cli.IntFlag{ |