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: make Tx dedupe cache maxSize configurable #5419

Merged
merged 7 commits into from
Jun 2, 2023
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
4 changes: 4 additions & 0 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ type Local struct {
// - sqlite (default)
// - pebbledb (experimental, in development)
StorageEngine string `version[28]:"sqlite"`

// TxIncomingFilterMaxSize sets the maximum size for the de-duplication cache used by the incoming tx filter
// only relevant if TxIncomingFilteringFlags is non-zero
TxIncomingFilterMaxSize uint64 `version[28]:"500000"`
}

// DNSBootstrapArray returns an array of one or more DNS Bootstrap identifiers
Expand Down
1 change: 1 addition & 0 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ var defaultLocal = Local{
TxBacklogReservedCapacityPerPeer: 20,
TxBacklogServiceRateWindowSeconds: 10,
TxBacklogSize: 26000,
TxIncomingFilterMaxSize: 500000,
TxIncomingFilteringFlags: 1,
TxPoolExponentialIncreaseFactor: 2,
TxPoolSize: 75000,
Expand Down
6 changes: 2 additions & 4 deletions data/txHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,11 @@
streamVerifierDropped: make(chan *verify.UnverifiedTxnSigJob),
}

// use defaultBacklogSize = approx number of txns in a full block as a parameter for the dedup cache size
Copy link
Contributor

Choose a reason for hiding this comment

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

Your PR describes what change is being made, but could you also include why? it would be helpful if we ever need to refer back to this change. This comment describes a reasonable estimation, so why 10x it?
(I know we've discussed it plenty in team settings, but I want to make sure it's recorded)

defaultBacklogSize := config.GetDefaultLocal().TxBacklogSize
if opts.Config.TxFilterRawMsgEnabled() {
handler.msgCache = makeSaltedCache(2 * defaultBacklogSize)
handler.msgCache = makeSaltedCache(int(opts.Config.TxIncomingFilterMaxSize))
}
if opts.Config.TxFilterCanonicalEnabled() {
handler.txCanonicalCache = makeDigestCache(2 * defaultBacklogSize)
handler.txCanonicalCache = makeDigestCache(int(opts.Config.TxIncomingFilterMaxSize))

Check warning on line 178 in data/txHandler.go

View check run for this annotation

Codecov / codecov/patch

data/txHandler.go#L178

Added line #L178 was not covered by tests
}

if opts.Config.EnableTxBacklogRateLimiting {
Expand Down
1 change: 1 addition & 0 deletions installer/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"TxBacklogReservedCapacityPerPeer": 20,
"TxBacklogServiceRateWindowSeconds": 10,
"TxBacklogSize": 26000,
"TxIncomingFilterMaxSize": 500000,
"TxIncomingFilteringFlags": 1,
"TxPoolExponentialIncreaseFactor": 2,
"TxPoolSize": 75000,
Expand Down
3 changes: 3 additions & 0 deletions test/testdata/configs/config-v28.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"EnableCatchupFromArchiveServers": false,
"EnableDeveloperAPI": false,
"EnableExperimentalAPI": false,
"EnableFollowMode": false,
"EnableGossipBlockService": true,
"EnableIncomingMessageFilter": false,
"EnableLedgerService": false,
Expand All @@ -53,6 +54,7 @@
"EnableRuntimeMetrics": false,
"EnableTopAccountsReporting": false,
"EnableTxBacklogRateLimiting": false,
"EnableTxnEvalTracer": false,
"EnableUsageLog": false,
"EnableVerbosedTransactionSyncLogging": false,
"EndpointAddress": "127.0.0.1:0",
Expand Down Expand Up @@ -107,6 +109,7 @@
"TxBacklogReservedCapacityPerPeer": 20,
"TxBacklogServiceRateWindowSeconds": 10,
"TxBacklogSize": 26000,
"TxIncomingFilterMaxSize": 500000,
"TxIncomingFilteringFlags": 1,
"TxPoolExponentialIncreaseFactor": 2,
"TxPoolSize": 75000,
Expand Down