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

txnsync: Use dynamic maxEncodedTransactionGroups #3168

Merged
merged 5 commits into from
Oct 29, 2021

Conversation

ghost
Copy link

@ghost ghost commented Oct 29, 2021

Summary

Change constants in the txnsync around message size limits into variables based on maxTxPoolSize. This will allow for support of larger message sizes when dealing with larger load.

Test Plan

Reran existing tests

@@ -51,6 +51,13 @@ func MakeTransactionSyncService(log logging.Logger, conn NodeConnector, isRelay
}
s.state.service = s
s.state.xorBuilder.MaxIterations = 10
if cfg.TxPoolSize > maxEncodedTransactionGroups {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks correct, but think it would be cleaner if you'll move all that logic into a single method which would be called by both init() as well as from here.

Copy link
Author

Choose a reason for hiding this comment

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

what is init()?

Copy link
Contributor

Choose a reason for hiding this comment

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

init methods are called when the package is loaded. In this case, instead of initializing the global variables where they are declared, call

func init() {
    setTransactionSyncVariables(config.GetDefaultLocal())
}
...
func setTransactionSyncVariables(cfg config.Local) {
        if cfg.TxPoolSize < maxEncodedTransactionGroups {
              return
        }
 	maxEncodedTransactionGroups = cfg.TxPoolSize
 	maxEncodedTransactionGroupEntries = cfg.TxPoolSize
 	maxBitmaskSize = (maxEncodedTransactionGroupEntries+7)/8 + 1
 	maxSignatureBytes = maxEncodedTransactionGroupEntries * len(crypto.Signature{})
 	maxAddressBytes = maxEncodedTransactionGroupEntries * crypto.DigestSize

 	maxBloomFilterSize = cfg.TxPoolSize * 5 // 32 bit xor uses slightly more than 4 bytes/element.
 	maxEncodedTransactionGroupBytes = cfg.TxPoolSize * 10000 // assume each transaction takes 10KB, as a worst-case-scenario for bounding purposes only.
 }

@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2021

Codecov Report

Merging #3168 (848e441) into master (e2d6349) will decrease coverage by 0.00%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3168      +/-   ##
==========================================
- Coverage   43.77%   43.77%   -0.01%     
==========================================
  Files         391      391              
  Lines       86880    86891      +11     
==========================================
- Hits        38036    38033       -3     
- Misses      42810    42820      +10     
- Partials     6034     6038       +4     
Impacted Files Coverage Δ
txnsync/encodedgroupstypes.go 100.00% <ø> (ø)
txnsync/txngroups.go 68.42% <0.00%> (ø)
txnsync/service.go 93.75% <81.81%> (-6.25%) ⬇️
txnsync/incoming.go 94.82% <100.00%> (ø)
network/wsPeer.go 68.53% <0.00%> (-2.14%) ⬇️
ledger/blockqueue.go 81.03% <0.00%> (-1.15%) ⬇️
data/abi/abi_type.go 92.03% <0.00%> (-1.00%) ⬇️
ledger/acctupdates.go 64.25% <0.00%> (-0.60%) ⬇️
network/wsNetwork.go 64.50% <0.00%> (ø)
catchup/service.go 69.32% <0.00%> (+0.24%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2d6349...848e441. Read the comment docs.

@tsachiherman tsachiherman assigned ghost Oct 29, 2021
@tsachiherman tsachiherman changed the title Use dynamic maxEncodedTransactionGroups txnsync: Use dynamic maxEncodedTransactionGroups Oct 29, 2021
@tsachiherman tsachiherman merged commit 21c752e into algorand:master Oct 29, 2021
tsachiherman added a commit to tsachiherman/go-algorand that referenced this pull request Nov 2, 2021
ghost pushed a commit to nicholasguo/go-algorand that referenced this pull request Nov 18, 2021
Change constants in the txnsync around message size limits into variables based on maxTxPoolSize. This will allow for support of larger message sizes when dealing with larger load.

Reran existing tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants