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

test: measures the max receive rate and adds a test to ensure the max rate is observed #1119

Merged
merged 26 commits into from
Oct 25, 2023

Conversation

staheri14
Copy link
Contributor

Closes #1111

@staheri14 staheri14 self-assigned this Oct 17, 2023
@staheri14 staheri14 marked this pull request as ready for review October 20, 2023 21:55
rootulp
rootulp previously approved these changes Oct 21, 2023
evan-forbes
evan-forbes previously approved these changes Oct 23, 2023
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

we should probably remove these print statements, but other than that LGTM!

p2p/conn/connection_test.go Outdated Show resolved Hide resolved
p2p/conn/connection_test.go Outdated Show resolved Hide resolved
@staheri14 staheri14 dismissed stale reviews from evan-forbes and rootulp via 83b377f October 23, 2023 21:12
evan-forbes
evan-forbes previously approved these changes Oct 23, 2023
require.Nil(t, err)
defer serverConn.Stop() //nolint:errcheck // ignore for tests

msgSize := int(cnfg.RecvRate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want a message size to be greater than the RecvRate so we can assert that MConnection correctly throttles the messages to that peer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason of why msgSize equal to cnfg.RecvRate would serve the purpose of this test is that the traffic rate is actually enforced roughly for every 100 ms (with the max traffic rate of RecvRate/10), and, roughly speaking, the peak rate is also measured based on the traffic rate observed in each 100 ms intervals. As such, a message size configured with cnfg.RecvRate can still lead to a sudden increase in traffic for a 100 ms interval hence resulting in a higher peak rate than allowed, which is exactly the purpose of this test. However, these specifics may not be immediately apparent when examining the test. Therefore, I agree that it would be more sensible to set the message size to a higher value to prevent any potential confusion. Going to update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see d71e935

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

👍

@staheri14 staheri14 merged commit ffdb652 into main Oct 25, 2023
16 checks passed
@staheri14 staheri14 deleted the sanaz/expected-rec-rate branch October 25, 2023 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Examining the enforcement of Send and Receive rates in P2P configuration
4 participants