From e2d46b556302e5509d8f2047825b5ce2f746ff34 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 4 Mar 2012 11:18:27 +0000 Subject: [PATCH] add performance warning when hitting the file descriptor limit. Log the total number of peers, including half-open TCP connections --- include/libtorrent/alert_types.hpp | 6 +++ parse_session_stats.py | 6 +-- src/alert.cpp | 3 +- src/session_impl.cpp | 66 +++++++++++++++++------------- 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index de0a07278..ff86f3252 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -226,6 +226,12 @@ namespace libtorrent bittyrant_with_no_uplimit, too_high_disk_queue_limit, too_few_outgoing_ports, + too_few_file_descriptors, + + + + + num_warnings diff --git a/parse_session_stats.py b/parse_session_stats.py index 4ff56b925..f8c59f433 100755 --- a/parse_session_stats.py +++ b/parse_session_stats.py @@ -125,9 +125,9 @@ def gen_html(reports, generations): reports = [ ('torrents', 'num', '', 'number of torrents in different torrent states', ['downloading torrents', 'seeding torrents', 'checking torrents', 'stopped torrents', 'upload-only torrents', 'error torrents']), - ('peers', 'num', '', 'num connected peers', ['peers', 'connecting peers', 'connection attempts', 'banned peers']), - ('peers_max', 'num', '', 'num connected peers', ['peers', 'connecting peers', 'connection attempts', 'banned peers', 'max connections']), - ('peer_churn', 'num', '', 'connecting and disconnecting peers', ['connecting peers', 'connection attempts', 'error peers']), + ('peers', 'num', '', 'num connected peers', ['peers', 'connecting peers', 'connection attempts', 'banned peers', 'total peers']), + ('peers_max', 'num', '', 'num connected peers', ['peers', 'connecting peers', 'connection attempts', 'banned peers', 'max connections', 'total peers']), + ('peer_churn', 'num', '', 'connecting and disconnecting peers', ['connecting peers', 'connection attempts']), ('connect_candidates', 'num', '', 'number of peers we know of that we can connect to', ['connect candidates']), ('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']), diff --git a/src/alert.cpp b/src/alert.cpp index 8e445a952..ceea03dd5 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -120,7 +120,8 @@ namespace libtorrent { "too many optimistic unchoke slots", "using bittyrant unchoker with no upload rate limit set", "the disk queue limit is too high compared to the cache size. The disk queue eats into the cache size", - "too few ports allowed for outgoing connections" + "too few ports allowed for outgoing connections", + "too few file descriptors are allowed for this process. connection limit lowered" }; return torrent_alert::message() + ": performance warning: " diff --git a/src/session_impl.cpp b/src/session_impl.cpp index e94cbb51c..d0e57454c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1074,6 +1074,36 @@ namespace aux { fclose(m_stats_logger); } + // make these cumulative for easier reading of graphs + // reset them every time the log is rotated though, + // to make them cumulative per one-hour graph + m_error_peers = 0; + m_disconnected_peers = 0; + m_eof_peers = 0; + m_connreset_peers = 0; + m_connrefused_peers = 0; + m_connaborted_peers = 0; + m_perm_peers = 0; + m_buffer_peers = 0; + m_unreachable_peers = 0; + m_broken_pipe_peers = 0; + m_addrinuse_peers = 0; + m_no_access_peers = 0; + m_invalid_arg_peers = 0; + m_aborted_peers = 0; + m_error_incoming_peers = 0; + m_error_outgoing_peers = 0; + m_error_rc4_peers = 0; + m_error_encrypted_peers = 0; + m_error_tcp_peers = 0; + m_error_utp_peers = 0; + m_connect_timeouts = 0; + m_uninteresting_peers = 0; + m_transport_timeout_peers = 0; + m_timeout_peers = 0; + m_no_memory_peers = 0; + m_too_many_peers = 0; + error_code ec; char filename[100]; create_directory("session_stats", ec); @@ -1228,6 +1258,8 @@ namespace aux { ":error encrypted peers" ":error tcp peers" ":error utp peers" + + ":total peers" "\n\n", m_stats_logger); } #endif @@ -2530,6 +2562,10 @@ namespace aux { , m_torrents.end(), boost::bind(&torrent::num_peers , boost::bind(&torrent_map::value_type::second, _1))); + if (m_alerts.should_post()) + m_alerts.post_alert(performance_alert( + torrent_handle(), performance_alert::too_few_file_descriptors)); + if (i != m_torrents.end()) { i->second->disconnect_peers(1, e); @@ -3512,34 +3548,6 @@ namespace aux { void session_impl::reset_stat_counters() { - // make these cumulative for easier reading of graphs -/* m_error_peers = 0; - m_disconnected_peers = 0; - m_eof_peers = 0; - m_connreset_peers = 0; - m_connrefused_peers = 0; - m_connaborted_peers = 0; - m_perm_peers = 0; - m_buffer_peers = 0; - m_unreachable_peers = 0; - m_broken_pipe_peers = 0; - m_addrinuse_peers = 0; - m_no_access_peers = 0; - m_invalid_arg_peers = 0; - m_aborted_peers = 0; - m_error_incoming_peers = 0; - m_error_outgoing_peers = 0; - m_error_rc4_peers = 0; - m_error_encrypted_peers = 0; - m_error_tcp_peers = 0; - m_error_utp_peers = 0; - m_connect_timeouts = 0; - m_uninteresting_peers = 0; - m_transport_timeout_peers = 0; - m_timeout_peers = 0; - m_no_memory_peers = 0; - m_too_many_peers = 0; -*/ m_end_game_piece_picker_blocks = 0; m_piece_picker_blocks = 0; m_piece_picks = 0; @@ -3920,6 +3928,8 @@ namespace aux { STAT_LOG(d, m_error_tcp_peers); STAT_LOG(d, m_error_utp_peers); + STAT_LOG(d, int(m_connections.size())); + fprintf(m_stats_logger, "\n"); #undef STAT_LOG