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

[5.0] P2P: Throttle over sync window #1811

Merged
merged 3 commits into from
Oct 24, 2023
Merged

[5.0] P2P: Throttle over sync window #1811

merged 3 commits into from
Oct 24, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Oct 23, 2023

Instead of calculating throttle limit from time of connection establishment, calculate over the specific enqueue sync window.
See #1741 for original implementation.

Update the throttle test to use more reasonable values.

Resolves #1808

…rom time of connection.

Updated test to use more reasonable values.
@heifner heifner changed the base branch from main to release/5.0 October 23, 2023 22:53
@heifner heifner added the OCI Work exclusive to OCI team label Oct 23, 2023
@heifner heifner linked an issue Oct 23, 2023 that may be closed by this pull request
@@ -892,6 +892,8 @@ namespace eosio {
std::atomic<size_t> bytes_sent{0};
std::atomic<size_t> block_sync_bytes_received{0};
std::atomic<size_t> block_sync_bytes_sent{0};
std::chrono::nanoseconds block_sync_send_start{0ns}; // start of enqueue blocks
size_t block_sync_send_bytes_sent{0}; // bytes sent in this set of enqueue blocks
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate to quibble over naming but block_sync_bytes_sent and block_sync_send_bytes_sent just blow my mind.
Can we rename this to something like:
block_sync_total_bytes_sent
block_sync_frame_bytes_sent ?

if( block_sync_rate_limit > 0 && block_sync_send_bytes_sent > 0 && peer_syncing_from_us ) {
auto now = get_time();
auto elapsed_us = std::chrono::duration_cast<std::chrono::microseconds>(now - block_sync_send_start);
double current_rate = (double(block_sync_bytes_sent) / elapsed_us.count()) * 100000;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are changing variables names from my comment above, please make this line a bit more readable by renaming current_rate to current_rate_sec or something like that. it will make it obvious that these are seconds and why you divide by 100'000. This is optional in case you are changing the code.

@heifner heifner merged commit def1432 into release/5.0 Oct 24, 2023
21 checks passed
@heifner heifner deleted the GH-1808-sync-5.0 branch October 24, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

p2p_sync_throttle_test failing on pinned builds
5 participants