Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilise a Flag to Toggle With the GC #4897

Merged
merged 2 commits into from Feb 18, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions beacon-chain/flags/base.go
Expand Up @@ -74,6 +74,12 @@ var (
Usage: "The eth1 block in which the deposit contract was deployed.",
Value: 1960177,
}
// SetGCPercent is the percentage of current live allocations at which the garbage collector is to run.
SetGCPercent = cli.IntFlag{
Name: "gc-percent",
Usage: "The percentage of freshly allocated data to live data on which the gc will be run again.",
Value: 100,
}
// SlasherCertFlag defines a flag for the slasher TLS certificate.
SlasherCertFlag = cli.StringFlag{
Name: "slasher-tls-cert",
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/main.go
Expand Up @@ -36,6 +36,7 @@ var appFlags = []cli.Flag{
flags.MinSyncPeers,
flags.RPCMaxPageSize,
flags.ContractDeploymentBlock,
flags.SetGCPercent,
flags.InteropMockEth1DataVotesFlag,
flags.InteropGenesisStateFlag,
flags.InteropNumValidatorsFlag,
Expand Down Expand Up @@ -126,6 +127,7 @@ func main() {
}
}

runtimeDebug.SetGCPercent(ctx.GlobalInt(flags.SetGCPercent.Name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be set if the flag is set, otherwise we are overriding the behavior of the environment variable

The initial setting is the value of the GOGC environment variable at startup, or 100 if the variable is not set.

runtime.GOMAXPROCS(runtime.NumCPU())
return debug.Setup(ctx)
}
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/usage.go
Expand Up @@ -89,6 +89,7 @@ var appHelpFlagGroups = []flagGroup{
flags.KeyFlag,
flags.GRPCGatewayPort,
flags.HTTPWeb3ProviderFlag,
flags.SetGCPercent,
},
},
{
Expand Down