move tracker transfer counters over to use performance_counters internally as well

This commit is contained in:
Arvid Norberg 2014-10-21 21:24:15 +00:00
parent bb3e399ce2
commit 7249122329
4 changed files with 14 additions and 52 deletions

View File

@ -160,26 +160,6 @@ namespace libtorrent
#endif
}
void received_tracker_bytes(int bytes)
{
TORRENT_ASSERT(bytes >= 0);
#ifndef TORRENT_DISABLE_FULL_STATS
m_stat[download_tracker_protocol].add(bytes);
#else
m_stat[download_protocol].add(bytes);
#endif
}
void sent_tracker_bytes(int bytes)
{
TORRENT_ASSERT(bytes >= 0);
#ifndef TORRENT_DISABLE_FULL_STATS
m_stat[upload_tracker_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);
@ -224,15 +204,11 @@ namespace libtorrent
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(); }
int download_tracker() const { return m_stat[download_tracker_protocol].counter(); }
int upload_tracker() const { return m_stat[upload_tracker_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; }
int download_tracker() const { return 0; }
int upload_tracker() const { return 0; }
#endif
// should be called once every second
@ -249,7 +225,6 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
+ m_stat[upload_ip_protocol].low_pass_rate()
+ m_stat[upload_dht_protocol].low_pass_rate()
+ m_stat[upload_tracker_protocol].low_pass_rate()
#endif
;
}
@ -261,7 +236,6 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
+ m_stat[download_ip_protocol].low_pass_rate()
+ m_stat[download_dht_protocol].low_pass_rate()
+ m_stat[download_tracker_protocol].low_pass_rate()
#endif
;
}
@ -273,7 +247,6 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
+ m_stat[upload_ip_protocol].rate()
+ m_stat[upload_dht_protocol].rate()
+ m_stat[upload_tracker_protocol].rate()
#endif
;
}
@ -285,7 +258,6 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
+ m_stat[download_ip_protocol].rate()
+ m_stat[download_dht_protocol].rate()
+ m_stat[download_tracker_protocol].rate()
#endif
;
}
@ -297,7 +269,6 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
+ m_stat[upload_ip_protocol].total()
+ m_stat[upload_dht_protocol].total()
+ m_stat[upload_tracker_protocol].total()
#endif
;
}
@ -309,7 +280,6 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
+ m_stat[download_ip_protocol].total()
+ m_stat[download_dht_protocol].total()
+ m_stat[download_tracker_protocol].total()
#endif
;
}
@ -362,10 +332,8 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_FULL_STATS
upload_ip_protocol,
upload_dht_protocol,
upload_tracker_protocol,
download_ip_protocol,
download_dht_protocol,
download_tracker_protocol,
#endif
num_channels
};

View File

@ -78,6 +78,7 @@ namespace libtorrent
class http_tracker_connection;
class udp_socket;
struct resolver_interface;
struct counters;
namespace aux { struct session_impl; struct session_settings; }
// returns -1 if gzip header is invalid or the header size in bytes
@ -376,6 +377,7 @@ namespace libtorrent
class udp_socket& m_udp_socket;
resolver_interface& m_host_resolver;
aux::session_settings const& m_settings;
counters& m_stats_counters;
bool m_abort;
};
}

View File

@ -3018,17 +3018,13 @@ retry:
{
peer_class* gpc = m_classes.at(m_global_class);
gpc->channel[peer_connection::download_channel].use_quota(
#ifndef TORRENT_DISABLE_DHT
m_stat.download_dht() +
gpc->channel[peer_connection::download_channel].use_quota(m_stat.download_dht());
#endif
m_stat.download_tracker());
gpc->channel[peer_connection::upload_channel].use_quota(
#ifndef TORRENT_DISABLE_DHT
m_stat.upload_dht() +
gpc->channel[peer_connection::upload_channel].use_quota(m_stat.upload_dht());
#endif
m_stat.upload_tracker());
int up_limit = upload_rate_limit(m_global_class);
int down_limit = download_rate_limit(m_global_class);
@ -4499,8 +4495,6 @@ retry:
, m_stat.total_transfer(stat::upload_payload));
m_stats_counters.set_value(counters::sent_ip_overhead_bytes
, m_stat.total_transfer(stat::upload_ip_protocol));
m_stats_counters.set_value(counters::sent_tracker_bytes
, m_stat.total_transfer(stat::upload_tracker_protocol));
m_stats_counters.set_value(counters::recv_bytes
, m_stat.total_download());
@ -4508,8 +4502,6 @@ retry:
, m_stat.total_transfer(stat::download_payload));
m_stats_counters.set_value(counters::recv_ip_overhead_bytes
, m_stat.total_transfer(stat::download_ip_protocol));
m_stats_counters.set_value(counters::recv_tracker_bytes
, m_stat.total_transfer(stat::download_tracker_protocol));
m_stats_counters.set_value(counters::limiter_up_queue
, m_upload_rate.queue_size());
@ -5353,6 +5345,8 @@ retry:
}
}
// TODO: 3 deprecate this function. All of this functionality should be
// exposed as performance counters
session_status session_impl::status() const
{
// INVARIANT_CHECK;
@ -5418,11 +5412,6 @@ retry:
s.total_dht_upload = 0;
#endif // TORRENT_DISABLE_DHT
// tracker
s.tracker_download_rate = m_stat.transfer_rate(stat::download_tracker_protocol);
s.total_tracker_download = m_stat.total_transfer(stat::download_tracker_protocol);
s.tracker_upload_rate = m_stat.transfer_rate(stat::upload_tracker_protocol);
s.total_tracker_upload = m_stat.total_transfer(stat::upload_tracker_protocol);
#else
// IP-overhead
s.ip_overhead_download_rate = 0;
@ -5435,13 +5424,15 @@ retry:
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];
// deprecated
s.tracker_download_rate = 0;
s.total_tracker_download = 0;
s.tracker_upload_rate = 0;
s.total_tracker_upload = 0;
#endif
#ifndef TORRENT_DISABLE_DHT
if (m_dht)

View File

@ -200,6 +200,7 @@ namespace libtorrent
, m_udp_socket(ses.m_udp_socket)
, m_host_resolver(ses.m_host_resolver)
, m_settings(ses.settings())
, m_stats_counters(ses.m_stats_counters)
, m_abort(false)
{}
@ -212,13 +213,13 @@ namespace libtorrent
void tracker_manager::sent_bytes(int bytes)
{
TORRENT_ASSERT(m_ses.is_single_thread());
m_ses.m_stat.sent_tracker_bytes(bytes);
m_stats_counters.inc_stats_counter(counters::sent_tracker_bytes, bytes);
}
void tracker_manager::received_bytes(int bytes)
{
TORRENT_ASSERT(m_ses.is_single_thread());
m_ses.m_stat.received_tracker_bytes(bytes);
m_stats_counters.inc_stats_counter(counters::recv_tracker_bytes, bytes);
}
void tracker_manager::remove_request(tracker_connection const* c)