Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Oct 19, 2021

Summary

Improve the bandwidth estimation within the transaction sync by having the estimation account for latency, transaction compression time, and time spent waiting in the incoming queue.

Test Plan

Wrote unit tests for correctness, ran network on mainnet model and observed measured bandwidths. Before the bandwidth would converge to the minimum over time as well have erratic inaccuracies. Now the numbers look much more in range, at most a factor of 2 off.

@ghost ghost marked this pull request as draft October 19, 2021 06:19
@ghost ghost changed the title Nguo/measurelatency Improve Bandwidth Estimation in Txnsync Oct 19, 2021
@tsachiherman tsachiherman assigned ghost Oct 19, 2021
@tsachiherman tsachiherman self-requested a review October 19, 2021 15:48
@tsachiherman
Copy link
Contributor

could you please rebase this PR ?

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

overall, I think that it looks good. Two small comments -

  1. The current code is calling s.node.GetPeerLatency on every incoming message. That's not horrible wrong, but it would make more sense to cache the latency at the Peer object, and refresh it only on new round and/or new peer.
  2. You've added quite many debug messages; while there is nothing wrong with that, I don't believe that there is a need to keep these on production code. Specifically for the transaction sync, it has its own logger - and the should be the way to log messages if we find that those are needed. ( I'm not sure if we really would get much value from the log messages added in this PR once we'll be over with these optimizations. ).

@ghost
Copy link
Author

ghost commented Oct 20, 2021

Yep, the log messages are only in the branch for testing purposes. I will remove them when I'm done testing.

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2021

Codecov Report

Merging #3096 (90ab7de) into master (48d4075) will decrease coverage by 0.01%.
The diff coverage is 78.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3096      +/-   ##
==========================================
- Coverage   43.70%   43.69%   -0.02%     
==========================================
  Files         391      391              
  Lines       86830    86841      +11     
==========================================
- Hits        37946    37942       -4     
- Misses      42849    42861      +12     
- Partials     6035     6038       +3     
Impacted Files Coverage Δ
node/txnSyncConn.go 0.00% <0.00%> (ø)
txnsync/interfaces.go 100.00% <ø> (ø)
txnsync/incoming.go 98.36% <66.66%> (-1.64%) ⬇️
txnsync/mainloop.go 85.84% <100.00%> (+0.13%) ⬆️
txnsync/outgoing.go 93.00% <100.00%> (+0.14%) ⬆️
txnsync/peer.go 93.61% <100.00%> (+0.01%) ⬆️
cmd/algoh/blockWatcher.go 77.77% <0.00%> (-3.18%) ⬇️
ledger/blockqueue.go 82.18% <0.00%> (-2.88%) ⬇️
agreement/cryptoVerifier.go 75.73% <0.00%> (-2.21%) ⬇️
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) ⬇️
... and 4 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 48d4075...90ab7de. Read the comment docs.

@ghost ghost force-pushed the nguo/measurelatency branch from 3c4033a to 3a1a43e Compare October 22, 2021 00:26
@ghost ghost marked this pull request as ready for review October 22, 2021 00:28
Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

Two small nits, but I think that this one is ready to be merged.

@tsachiherman
Copy link
Contributor

could you please go-lint over the changes ?

tsachiherman
tsachiherman previously approved these changes Oct 22, 2021
@ghost ghost force-pushed the nguo/measurelatency branch from 91f5e80 to 364e328 Compare October 22, 2021 23:45
Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

looks good.

@tsachiherman tsachiherman merged commit b93ad64 into algorand:master Oct 24, 2021
onetechnical pushed a commit that referenced this pull request Oct 25, 2021

## Summary


Improve the bandwidth estimation within the transaction sync by having the estimation account for latency, transaction compression time, and time spent waiting in the incoming queue.

## Test Plan


Wrote unit tests for correctness, ran network on mainnet model and observed measured bandwidths. Before the bandwidth would converge to the minimum over time as well have erratic inaccuracies. Now the numbers look much more in range, at most a factor of 2 off.
tsachiherman added a commit to tsachiherman/go-algorand that referenced this pull request Nov 2, 2021
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.

4 participants