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

config: Add GoMemLimit config option and use with 10-node test #5975

Merged
merged 4 commits into from
Jun 12, 2024
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
6 changes: 6 additions & 0 deletions cmd/algod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"math/rand"
"os"
"path/filepath"
"runtime/debug"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -173,6 +174,11 @@
log.Fatalf("Cannot load config: %v", err)
}

// set soft memory limit, if configured
if cfg.GoMemLimit > 0 {
debug.SetMemoryLimit(int64(cfg.GoMemLimit))

Check warning on line 179 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L178-L179

Added lines #L178 - L179 were not covered by tests
}

_, err = cfg.ValidateDNSBootstrapArray(genesis.Network)
if err != nil {
// log is not setup yet, this will log to stderr
Expand Down
6 changes: 5 additions & 1 deletion config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Local struct {
// Version tracks the current version of the defaults so we can migrate old -> new
// This is specifically important whenever we decide to change the default value
// for an existing parameter. This field tag must be updated any time we add a new version.
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28" version[29]:"29" version[30]:"30" version[31]:"31" version[32]:"32" version[33]:"33"`
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28" version[29]:"29" version[30]:"30" version[31]:"31" version[32]:"32" version[33]:"33" version[34]:"34"`

// Archival nodes retain a full copy of the block history. Non-Archival nodes will delete old blocks and only retain what's need to properly validate blockchain messages (the precise number of recent blocks depends on the consensus parameters. Currently the last 1321 blocks are required). This means that non-Archival nodes require significantly less storage than Archival nodes. If setting this to true for the first time, the existing ledger may need to be deleted to get the historical values stored as the setting only affects current blocks forward. To do this, shutdown the node and delete all .sqlite files within the data/testnet-version directory, except the crash.sqlite file. Restart the node and wait for the node to sync.
Archival bool `version[0]:"false"`
Expand Down Expand Up @@ -609,6 +609,10 @@ type Local struct {

// DisableAPIAuth turns off authentication for public (non-admin) API endpoints.
DisableAPIAuth bool `version[30]:"false"`

// GoMemLimit provides the Go runtime with a soft memory limit. The default behavior is no limit,
// unless the GOMEMLIMIT environment variable is set.
GoMemLimit uint64 `version[34]:"0"`
}

// DNSBootstrapArray returns an array of one or more DNS Bootstrap identifiers
Expand Down
3 changes: 2 additions & 1 deletion config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package config

var defaultLocal = Local{
Version: 33,
Version: 34,
AccountUpdatesStatsInterval: 5000000000,
AccountsRebuildSynchronousMode: 1,
AgreementIncomingBundlesQueueLength: 15,
Expand Down Expand Up @@ -89,6 +89,7 @@ var defaultLocal = Local{
FallbackDNSResolverAddress: "",
ForceFetchTransactions: false,
ForceRelayMessages: false,
GoMemLimit: 0,
GossipFanout: 4,
HeartbeatUpdateInterval: 600,
HotDataDir: "",
Expand Down
3 changes: 2 additions & 1 deletion installer/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": 33,
"Version": 34,
"AccountUpdatesStatsInterval": 5000000000,
"AccountsRebuildSynchronousMode": 1,
"AgreementIncomingBundlesQueueLength": 15,
Expand Down Expand Up @@ -68,6 +68,7 @@
"FallbackDNSResolverAddress": "",
"ForceFetchTransactions": false,
"ForceRelayMessages": false,
"GoMemLimit": 0,
"GossipFanout": 4,
"HeartbeatUpdateInterval": 600,
"HotDataDir": "",
Expand Down
6 changes: 6 additions & 0 deletions test/e2e-go/features/catchup/stateproofsCatchup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ func TestSendSigsAfterCatchpointCatchup(t *testing.T) {
var fixture fixtures.RestClientFixture
fixture.SetConsensus(configurableConsensus)
fixture.SetupNoStart(t, filepath.Join("nettemplates", "ThreeNodesWithRichAcct.json"))
for _, nodeDir := range fixture.NodeDataDirs() {
cfg, err := config.LoadConfigFromDisk(nodeDir)
a.NoError(err)
cfg.GoMemLimit = 4 * 1024 * 1024 * 1024 // 4GB
cfg.SaveToDisk(nodeDir)
}

primaryNode, primaryNodeRestClient, primaryEC := startCatchpointGeneratingNode(a, &fixture, "Primary")
defer primaryEC.Print()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func TestPartitionHalfOffline(t *testing.T) {
a.NoError(err)
// adjust the refresh interval for one hour, so that we won't be reloading the participation key during this test.
cfg.ParticipationKeysRefreshInterval = time.Hour
cfg.GoMemLimit = 1 * 1024 * 1024 * 1024 // 1GB
cfg.SaveToDisk(nodeDir)
}
fixture.Start()
algorandskiy marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
139 changes: 139 additions & 0 deletions test/testdata/configs/config-v34.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"Version": 34,
"AccountUpdatesStatsInterval": 5000000000,
"AccountsRebuildSynchronousMode": 1,
"AgreementIncomingBundlesQueueLength": 15,
"AgreementIncomingProposalsQueueLength": 50,
"AgreementIncomingVotesQueueLength": 20000,
"AnnounceParticipationKey": true,
"Archival": false,
"BaseLoggerDebugLevel": 4,
"BlockDBDir": "",
"BlockServiceCustomFallbackEndpoints": "",
"BlockServiceMemCap": 500000000,
"BroadcastConnectionsLimit": -1,
"CadaverDirectory": "",
"CadaverSizeTarget": 0,
"CatchpointDir": "",
"CatchpointFileHistoryLength": 365,
"CatchpointInterval": 10000,
"CatchpointTracking": 0,
"CatchupBlockDownloadRetryAttempts": 1000,
"CatchupBlockValidateMode": 0,
"CatchupFailurePeerRefreshRate": 10,
"CatchupGossipBlockFetchTimeoutSec": 4,
"CatchupHTTPBlockFetchTimeoutSec": 4,
"CatchupLedgerDownloadRetryAttempts": 50,
"CatchupParallelBlocks": 16,
"ColdDataDir": "",
"ConnectionsRateLimitingCount": 60,
"ConnectionsRateLimitingWindowSeconds": 1,
"CrashDBDir": "",
"DNSBootstrapID": "<network>.algorand.network?backup=<network>.algorand.net&dedup=<name>.algorand-<network>.(network|net)",
"DNSSecurityFlags": 1,
"DeadlockDetection": 0,
"DeadlockDetectionThreshold": 30,
"DisableAPIAuth": false,
"DisableLedgerLRUCache": false,
"DisableLocalhostConnectionRateLimit": true,
"DisableNetworking": false,
"DisableOutgoingConnectionThrottling": false,
"EnableAccountUpdatesStats": false,
"EnableAgreementReporting": false,
"EnableAgreementTimeMetrics": false,
"EnableAssembleStats": false,
"EnableBlockService": false,
"EnableDeveloperAPI": false,
"EnableExperimentalAPI": false,
"EnableFollowMode": false,
"EnableGossipBlockService": true,
"EnableGossipService": true,
"EnableIncomingMessageFilter": false,
"EnableLedgerService": false,
"EnableMetricReporting": false,
"EnableOutgoingNetworkMessageFiltering": true,
"EnableP2P": false,
"EnablePingHandler": true,
"EnableProcessBlockStats": false,
"EnableProfiler": false,
"EnableRequestLogger": false,
"EnableRuntimeMetrics": false,
"EnableTopAccountsReporting": false,
"EnableTxBacklogAppRateLimiting": true,
"EnableTxBacklogRateLimiting": true,
"EnableTxnEvalTracer": false,
"EnableUsageLog": false,
"EnableVerbosedTransactionSyncLogging": false,
"EndpointAddress": "127.0.0.1:0",
"FallbackDNSResolverAddress": "",
"ForceFetchTransactions": false,
"ForceRelayMessages": false,
"GoMemLimit": 0,
"GossipFanout": 4,
"HeartbeatUpdateInterval": 600,
"HotDataDir": "",
"IncomingConnectionsLimit": 2400,
"IncomingMessageFilterBucketCount": 5,
"IncomingMessageFilterBucketSize": 512,
"LedgerSynchronousMode": 2,
"LogArchiveDir": "",
"LogArchiveMaxAge": "",
"LogArchiveName": "node.archive.log",
"LogFileDir": "",
"LogSizeLimit": 1073741824,
"MaxAPIBoxPerApplication": 100000,
"MaxAPIResourcesPerAccount": 100000,
"MaxAcctLookback": 4,
"MaxBlockHistoryLookback": 0,
"MaxCatchpointDownloadDuration": 43200000000000,
"MaxConnectionsPerIP": 15,
"MinCatchpointFileDownloadBytesPerSecond": 20480,
"NetAddress": "",
"NetworkMessageTraceServer": "",
"NetworkProtocolVersion": "",
"NodeExporterListenAddress": ":9100",
"NodeExporterPath": "./node_exporter",
"OptimizeAccountsDatabaseOnStartup": false,
"OutgoingMessageFilterBucketCount": 3,
"OutgoingMessageFilterBucketSize": 128,
"P2PPersistPeerID": false,
"P2PPrivateKeyLocation": "",
"ParticipationKeysRefreshInterval": 60000000000,
"PeerConnectionsUpdateInterval": 3600,
"PeerPingPeriodSeconds": 0,
"PriorityPeers": {},
"ProposalAssemblyTime": 500000000,
"PublicAddress": "",
"ReconnectTime": 60000000000,
"ReservedFDs": 256,
"RestConnectionsHardLimit": 2048,
"RestConnectionsSoftLimit": 1024,
"RestReadTimeoutSeconds": 15,
"RestWriteTimeoutSeconds": 120,
"RunHosted": false,
"StateproofDir": "",
"StorageEngine": "sqlite",
"SuggestedFeeBlockHistory": 3,
"SuggestedFeeSlidingWindowSize": 50,
"TLSCertFile": "",
"TLSKeyFile": "",
"TelemetryToLog": true,
"TrackerDBDir": "",
"TransactionSyncDataExchangeRate": 0,
"TransactionSyncSignificantMessageThreshold": 0,
"TxBacklogAppTxPerSecondRate": 100,
"TxBacklogAppTxRateLimiterMaxSize": 1048576,
"TxBacklogRateLimitingCongestionPct": 50,
"TxBacklogReservedCapacityPerPeer": 20,
"TxBacklogServiceRateWindowSeconds": 10,
"TxBacklogSize": 26000,
"TxIncomingFilterMaxSize": 500000,
"TxIncomingFilteringFlags": 1,
"TxPoolExponentialIncreaseFactor": 2,
"TxPoolSize": 75000,
"TxSyncIntervalSeconds": 60,
"TxSyncServeResponseSize": 1000000,
"TxSyncTimeoutSeconds": 30,
"UseXForwardedForAddressField": "",
"VerifiedTranscationsCacheSize": 150000
}
Loading