diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 22ba49894..2e81033e4 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -465,6 +465,8 @@ namespace libtorrent { num_utp_close_wait, num_utp_deleted, + num_outstanding_accept, + num_counters, num_gauges_counters = num_counters - num_stats_counters }; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index d57bd8f19..fe7ac2087 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2533,6 +2533,7 @@ namespace aux { #endif std::weak_ptr ls(listener); + m_stats_counters.inc_stats_counter(counters::num_outstanding_accept); listener->async_accept(*str, [this, c, ls, ssl] (error_code const& ec) { return this->wrap(&session_impl::on_accept_connection, c, ls, ec, ssl); }); } @@ -2543,6 +2544,8 @@ namespace aux { { COMPLETE_ASYNC("session_impl::on_accept_connection"); m_stats_counters.inc_stats_counter(counters::on_accept_counter); + m_stats_counters.inc_stats_counter(counters::num_outstanding_accept, -1); + TORRENT_ASSERT(is_single_thread()); std::shared_ptr listener = listen_socket.lock(); if (!listener) return; diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 533dc22dd..21e634cf3 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -252,6 +252,10 @@ namespace { // the number of allowed unchoked peers METRIC(ses, num_unchoke_slots) + // the number of listen sockets that are currently accepting incoming + // connections + METRIC(ses, num_outstanding_accept) + // bittorrent message counters. These counters are incremented // every time a message of the corresponding type is received from // or sent to a bittorrent peer. diff --git a/tools/parse_session_stats.py b/tools/parse_session_stats.py index 78cb8c5ef..9c7767bc9 100755 --- a/tools/parse_session_stats.py +++ b/tools/parse_session_stats.py @@ -624,6 +624,9 @@ reports = [ 'picker.piece_picker_rand_loops', \ 'picker.piece_picker_busy_loops' \ ], {'type': stacked}), + ('async_accept', 'number of outstanding accept calls', '', '', [ \ + 'ses.num_outstanding_accept' \ + ]), # ('picker_full_partials_distribution', 'full pieces', '', '', ['num full partial pieces'], # {'type': histogram, 'binwidth': 5, 'numbins': 120}),