From ce9ff9885b537cad2e2dba9ed28a0f3a4379cc19 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 21 Oct 2014 21:36:45 +0000 Subject: [PATCH] move DHT transfer counters to performance_counters --- include/libtorrent/performance_counters.hpp | 2 + include/libtorrent/stat.hpp | 32 ---------------- src/session_impl.cpp | 41 ++++++--------------- src/session_stats.cpp | 4 ++ 4 files changed, 18 insertions(+), 61 deletions(-) diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 4bb8cd9a3..eb7e4a457 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -227,6 +227,8 @@ namespace libtorrent dht_get_out, dht_put_in, dht_put_out, + sent_dht_bytes, + recv_dht_bytes, // uTP counters utp_packet_loss, diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index 7f93dddbf..82e42cf79 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -140,26 +140,6 @@ namespace libtorrent #endif } - void received_dht_bytes(int bytes) - { - TORRENT_ASSERT(bytes >= 0); -#ifndef TORRENT_DISABLE_FULL_STATS - m_stat[download_dht_protocol].add(bytes); -#else - m_stat[download_protocol].add(bytes); -#endif - } - - void sent_dht_bytes(int bytes) - { - TORRENT_ASSERT(bytes >= 0); -#ifndef TORRENT_DISABLE_FULL_STATS - m_stat[upload_dht_protocol].add(bytes); -#else - m_stat[upload_protocol].add(bytes); -#endif - } - void received_bytes(int bytes_payload, int bytes_protocol) { TORRENT_ASSERT(bytes_payload >= 0); @@ -202,13 +182,9 @@ namespace libtorrent #ifndef TORRENT_DISABLE_FULL_STATS int upload_ip_overhead() const { return m_stat[upload_ip_protocol].counter(); } int download_ip_overhead() const { return m_stat[download_ip_protocol].counter(); } - int upload_dht() const { return m_stat[upload_dht_protocol].counter(); } - int download_dht() const { return m_stat[download_dht_protocol].counter(); } #else int upload_ip_overhead() const { return 0; } int download_ip_overhead() const { return 0; } - int upload_dht() const { return 0; } - int download_dht() const { return 0; } #endif // should be called once every second @@ -224,7 +200,6 @@ namespace libtorrent + m_stat[upload_protocol].low_pass_rate() #ifndef TORRENT_DISABLE_FULL_STATS + m_stat[upload_ip_protocol].low_pass_rate() - + m_stat[upload_dht_protocol].low_pass_rate() #endif ; } @@ -235,7 +210,6 @@ namespace libtorrent + m_stat[download_protocol].low_pass_rate() #ifndef TORRENT_DISABLE_FULL_STATS + m_stat[download_ip_protocol].low_pass_rate() - + m_stat[download_dht_protocol].low_pass_rate() #endif ; } @@ -246,7 +220,6 @@ namespace libtorrent + m_stat[upload_protocol].rate() #ifndef TORRENT_DISABLE_FULL_STATS + m_stat[upload_ip_protocol].rate() - + m_stat[upload_dht_protocol].rate() #endif ; } @@ -257,7 +230,6 @@ namespace libtorrent + m_stat[download_protocol].rate() #ifndef TORRENT_DISABLE_FULL_STATS + m_stat[download_ip_protocol].rate() - + m_stat[download_dht_protocol].rate() #endif ; } @@ -268,7 +240,6 @@ namespace libtorrent + m_stat[upload_protocol].total() #ifndef TORRENT_DISABLE_FULL_STATS + m_stat[upload_ip_protocol].total() - + m_stat[upload_dht_protocol].total() #endif ; } @@ -279,7 +250,6 @@ namespace libtorrent + m_stat[download_protocol].total() #ifndef TORRENT_DISABLE_FULL_STATS + m_stat[download_ip_protocol].total() - + m_stat[download_dht_protocol].total() #endif ; } @@ -331,9 +301,7 @@ namespace libtorrent download_protocol, #ifndef TORRENT_DISABLE_FULL_STATS upload_ip_protocol, - upload_dht_protocol, download_ip_protocol, - download_dht_protocol, #endif num_channels }; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index aae7e4db9..08f945c3e 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3003,13 +3003,13 @@ retry: } #ifndef TORRENT_DISABLE_DHT + int dht_down = 0; + int dht_up = 0; if (m_dht) { - int dht_down; - int dht_up; m_dht->network_stats(dht_up, dht_down); - m_stat.sent_dht_bytes(dht_up); - m_stat.received_dht_bytes(dht_down); + m_stats_counters.inc_stats_counter(counters::sent_dht_bytes, dht_up); + m_stats_counters.inc_stats_counter(counters::recv_dht_bytes, dht_down); } #endif @@ -3019,11 +3019,8 @@ retry: peer_class* gpc = m_classes.at(m_global_class); #ifndef TORRENT_DISABLE_DHT - gpc->channel[peer_connection::download_channel].use_quota(m_stat.download_dht()); -#endif - -#ifndef TORRENT_DISABLE_DHT - gpc->channel[peer_connection::upload_channel].use_quota(m_stat.upload_dht()); + gpc->channel[peer_connection::download_channel].use_quota(dht_down); + gpc->channel[peer_connection::upload_channel].use_quota(dht_up); #endif int up_limit = upload_rate_limit(m_global_class); @@ -5398,41 +5395,27 @@ retry: s.total_ip_overhead_download = m_stat.total_transfer(stat::download_ip_protocol); s.ip_overhead_upload_rate = m_stat.transfer_rate(stat::upload_ip_protocol); s.total_ip_overhead_upload = m_stat.total_transfer(stat::upload_ip_protocol); - -#ifndef TORRENT_DISABLE_DHT - // DHT protocol - s.dht_download_rate = m_stat.transfer_rate(stat::download_dht_protocol); - s.total_dht_download = m_stat.total_transfer(stat::download_dht_protocol); - s.dht_upload_rate = m_stat.transfer_rate(stat::upload_dht_protocol); - s.total_dht_upload = m_stat.total_transfer(stat::upload_dht_protocol); -#else - s.dht_download_rate = 0; - s.total_dht_download = 0; - s.dht_upload_rate = 0; - s.total_dht_upload = 0; -#endif // TORRENT_DISABLE_DHT - #else // IP-overhead s.ip_overhead_download_rate = 0; s.total_ip_overhead_download = 0; s.ip_overhead_upload_rate = 0; s.total_ip_overhead_upload = 0; - - // DHT protocol - s.dht_download_rate = 0; - s.total_dht_download = 0; - s.dht_upload_rate = 0; - s.total_dht_upload = 0; #endif // tracker s.total_tracker_download = m_stats_counters[counters::recv_tracker_bytes]; s.total_tracker_upload = m_stats_counters[counters::sent_tracker_bytes]; + // dht + s.total_dht_download = m_stats_counters[counters::recv_dht_bytes]; + s.total_dht_upload = m_stats_counters[counters::sent_dht_bytes]; + // deprecated s.tracker_download_rate = 0; s.tracker_upload_rate = 0; + s.dht_download_rate = 0; + s.dht_upload_rate = 0; #ifndef TORRENT_DISABLE_DHT if (m_dht) diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 3997c160c..244e6a3cc 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -416,6 +416,10 @@ namespace libtorrent METRIC(dht, dht_put_in) METRIC(dht, dht_put_out) + // the number of bytes sent and received by the DHT + METRIC(dht, sent_dht_bytes) + METRIC(dht, recv_dht_bytes) + // uTP counters. Each counter represents the number of time each event // has occurred. METRIC(utp, utp_packet_loss)