-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
…rom time of connection. Updated test to use more reasonable values.
plugins/net_plugin/net_plugin.cpp
Outdated
@@ -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 |
There was a problem hiding this comment.
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
?
plugins/net_plugin/net_plugin.cpp
Outdated
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; |
There was a problem hiding this comment.
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.
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