aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/connection_basic.cpp
diff options
context:
space:
mode:
authorrbrunner7 <rbrunner@dreamshare.ch>2017-11-26 15:26:17 +0100
committerrbrunner7 <rbrunner@dreamshare.ch>2017-11-28 21:18:01 +0100
commitcf5f62361682877a08b246a0d04827c5c4cc30f5 (patch)
treec7feb58c06bf0f3ed0396baa93ea0e95c032887b /src/p2p/connection_basic.cpp
parentMerge pull request #2827 (diff)
downloadmonero-cf5f62361682877a08b246a0d04827c5c4cc30f5.tar.xz
Corrections in rate limiting / trottle code, especially in 'out' direction
Deleted 3 out of 4 calls to method connection_basic::sleep_before_packet that were erroneous / superfluous, which enabled the elimination of a "fudge" factor of 2.1 in connection_basic::set_rate_up_limit; also ended the multiplying of limit values and numbers of bytes transferred by 1024 before handing them over to the global throttle objects
Diffstat (limited to 'src/p2p/connection_basic.cpp')
-rw-r--r--src/p2p/connection_basic.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/p2p/connection_basic.cpp b/src/p2p/connection_basic.cpp
index 8edd75b3e..06baa7893 100644
--- a/src/p2p/connection_basic.cpp
+++ b/src/p2p/connection_basic.cpp
@@ -173,14 +173,9 @@ connection_basic::~connection_basic() noexcept(false) {
}
void connection_basic::set_rate_up_limit(uint64_t limit) {
-
- // TODO remove __SCALING_FACTOR...
- const double SCALING_FACTOR = 2.1; // to acheve the best performance
- limit *= SCALING_FACTOR;
{
CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
network_throttle_manager::get_global_throttle_out().set_target_speed(limit);
- network_throttle_manager::get_global_throttle_out().set_real_target_speed(limit / SCALING_FACTOR);
}
save_limit_to_file(limit);
}
@@ -238,7 +233,7 @@ void connection_basic::sleep_before_packet(size_t packet_size, int phase, int q
{
CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
- delay = network_throttle_manager::get_global_throttle_out().get_sleep_time_after_tick( packet_size ); // decission from global
+ delay = network_throttle_manager::get_global_throttle_out().get_sleep_time_after_tick( packet_size );
}
delay *= 0.50;
@@ -252,7 +247,7 @@ void connection_basic::sleep_before_packet(size_t packet_size, int phase, int q
// XXX LATER XXX
{
CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
- network_throttle_manager::get_global_throttle_out().handle_trafic_exact( packet_size * 700); // increase counter - global
+ network_throttle_manager::get_global_throttle_out().handle_trafic_exact( packet_size ); // increase counter - global
}
}
@@ -262,13 +257,13 @@ void connection_basic::set_start_time() {
}
void connection_basic::do_send_handler_write(const void* ptr , size_t cb ) {
- sleep_before_packet(cb,1,-1);
+ // No sleeping here; sleeping is done once and for all in connection<t_protocol_handler>::handle_write
MTRACE("handler_write (direct) - before ASIO write, for packet="<<cb<<" B (after sleep)");
set_start_time();
}
void connection_basic::do_send_handler_write_from_queue( const boost::system::error_code& e, size_t cb, int q_len ) {
- sleep_before_packet(cb,2,q_len);
+ // No sleeping here; sleeping is done once and for all in connection<t_protocol_handler>::handle_write
MTRACE("handler_write (after write, from queue="<<q_len<<") - before ASIO write, for packet="<<cb<<" B (after sleep)");
set_start_time();