log stats of incoming piece requests

This commit is contained in:
Arvid Norberg 2012-03-09 06:24:01 +00:00
parent e08718428e
commit b58a96d76b
5 changed files with 59 additions and 0 deletions

View File

@ -976,6 +976,13 @@ namespace libtorrent
int m_invalid_arg_peers;
int m_aborted_peers;
int m_piece_requests;
int m_max_piece_requests;
int m_invalid_piece_requests;
int m_choked_piece_requests;
int m_cancelled_piece_requests;
int m_piece_rejects;
int m_error_incoming_peers;
int m_error_outgoing_peers;
int m_error_rc4_peers;

View File

@ -134,6 +134,7 @@ reports = [
('peers_list_size', 'num', '', 'number of known peers (not necessarily connected)', ['num list peers']),
('overall_rates', 'rate', 'B/s', 'download and upload rates', ['uploaded bytes', 'downloaded bytes', 'upload rate', 'download rate', 'smooth upload rate', 'smooth download rate']),
('disk_write_queue', 'Bytes', 'B', 'bytes queued up by peers, to be written to disk', ['disk write queued bytes', 'disk queue limit', 'disk queue low watermark']),
('peers_requests', 'num', '', 'incoming piece request rate', ['piece requests', 'piece rejects', 'max piece requests', 'invalid piece requests', 'choked piece requests', 'cancelled piece requests']),
('peers_upload', 'num', '', 'number of peers by state wrt. uploading', ['peers up interested', 'peers up unchoked', 'peers up requests', 'peers disk-up', 'peers bw-up', 'max unchoked']),
('peers_download', 'num', '', 'number of peers by state wrt. downloading', ['peers down interesting', 'peers down unchoked', 'peers down requests', 'peers disk-down', 'peers bw-down','num end-game peers']),
('peer_errors', 'num', '', 'number of peers by error that disconnected them', ['error peers', 'peer disconnects', 'peers eof', 'peers connection reset', 'connect timeouts', 'uninteresting peers disconnect', 'banned for hash failure', 'no memory peer errors', 'too many peers', 'transport timeout peers', 'connection refused peers', 'connection aborted peers', 'permission denied peers', 'no buffer peers', 'host unreachable peers', 'broken pipe peers', 'address in use peers', 'access denied peers', 'invalid argument peers', 'operation aborted peers']),

View File

@ -331,6 +331,10 @@ namespace libtorrent
{
INVARIANT_CHECK;
#ifdef TORRENT_STATS
++m_ses.m_piece_rejects;
#endif
if (!m_supports_fast) return;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);

View File

@ -2023,6 +2023,10 @@ namespace libtorrent
boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t);
#ifdef TORRENT_STATS
++m_ses.m_piece_requests;
#endif
#if defined TORRENT_VERBOSE_LOGGING
peer_log("<== REQUEST [ piece: %d s: %d l: %d ]"
, r.piece, r.start, r.length);
@ -2031,6 +2035,9 @@ namespace libtorrent
if (m_superseed_piece != -1
&& r.piece != m_superseed_piece)
{
#ifdef TORRENT_STATS
++m_ses.m_invalid_piece_requests;
#endif
++m_num_invalid_requests;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
peer_log("*** INVALID_REQUEST [ piece not superseeded "
@ -2066,6 +2073,9 @@ namespace libtorrent
if (!t->valid_metadata())
{
#ifdef TORRENT_STATS
++m_ses.m_invalid_piece_requests;
#endif
// if we don't have valid metadata yet,
// we shouldn't get a request
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
@ -2079,6 +2089,9 @@ namespace libtorrent
if (int(m_requests.size()) > m_ses.settings().max_allowed_in_request_queue)
{
#ifdef TORRENT_STATS
++m_ses.m_max_piece_requests;
#endif
// don't allow clients to abuse our
// memory consumption.
// ignore requests if the client
@ -2115,6 +2128,9 @@ namespace libtorrent
peer_log("*** REJECTING REQUEST [ peer choked and piece not in allowed fast set ]");
peer_log(" ==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
, r.piece, r.start, r.length);
#endif
#ifdef TORRENT_STATS
++m_ses.m_choked_piece_requests;
#endif
write_reject_request(r);
++m_choke_rejects;
@ -2148,6 +2164,9 @@ namespace libtorrent
}
else
{
#ifdef TORRENT_STATS
++m_ses.m_invalid_piece_requests;
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
peer_log("*** INVALID_REQUEST [ "
"i: %d t: %d n: %d h: %d block_limit: %d ]"
@ -2682,6 +2701,9 @@ namespace libtorrent
if (i != m_requests.end())
{
#ifdef TORRENT_STATS
++m_ses.m_cancelled_piece_requests;
#endif
m_requests.erase(i);
#ifdef TORRENT_VERBOSE_LOGGING
peer_log("==> REJECT_PIECE [ piece: %d s: %d l: %d ]"
@ -3142,6 +3164,9 @@ namespace libtorrent
continue;
}
peer_request const& r = *i;
#ifdef TORRENT_STATS
++m_ses.m_choked_piece_requests;
#endif
#ifdef TORRENT_VERBOSE_LOGGING
peer_log("==> REJECT_PIECE [ piece: %d s: %d l: %d ]"
, r.piece , r.start , r.length);

View File

@ -1267,6 +1267,14 @@ namespace aux {
":torrents want more peers"
":average peers per limit"
":piece requests"
":max piece requests"
":invalid piece requests"
":choked piece requests"
":cancelled piece requests"
":piece rejects"
"\n\n", m_stats_logger);
}
#endif
@ -3568,6 +3576,13 @@ namespace aux {
m_num_banned_peers = 0;
m_banned_for_hash_failure = 0;
m_piece_requests = 0;
m_max_piece_requests = 0;
m_invalid_piece_requests = 0;
m_choked_piece_requests = 0;
m_cancelled_piece_requests = 0;
m_piece_rejects = 0;
memset(m_num_messages, 0, sizeof(m_num_messages));
memset(m_send_buffer_sizes, 0, sizeof(m_send_buffer_sizes));
memset(m_recv_buffer_sizes, 0, sizeof(m_recv_buffer_sizes));
@ -3961,6 +3976,13 @@ namespace aux {
STAT_LOG(d, num_want_more_peers);
STAT_LOG(f, total_peers_limit == 0 ? 0 : float(num_limited_peers) / total_peers_limit);
STAT_LOG(d, m_piece_requests);
STAT_LOG(d, m_max_piece_requests);
STAT_LOG(d, m_invalid_piece_requests);
STAT_LOG(d, m_choked_piece_requests);
STAT_LOG(d, m_cancelled_piece_requests);
STAT_LOG(d, m_piece_rejects);
fprintf(m_stats_logger, "\n");
#undef STAT_LOG