add a few more stats counters measuring outgoing connection attempts. simplify session_stats_header_alert by posting it on first call to post_session_stats() instead of making it gated by the alert_mask
This commit is contained in:
parent
28bd7102be
commit
7be9547817
|
@ -536,8 +536,12 @@ class test_session(unittest.TestCase):
|
||||||
while len(alerts) == 0:
|
while len(alerts) == 0:
|
||||||
s.wait_for_alert(1000)
|
s.wait_for_alert(1000)
|
||||||
alerts = s.pop_alerts()
|
alerts = s.pop_alerts()
|
||||||
|
|
||||||
|
while len(alerts) > 0:
|
||||||
a = alerts.pop(0)
|
a = alerts.pop(0)
|
||||||
print(a)
|
print(a)
|
||||||
|
if isinstance(a, lt.session_stats_header_alert):
|
||||||
|
break
|
||||||
self.assertTrue(isinstance(a, lt.session_stats_header_alert))
|
self.assertTrue(isinstance(a, lt.session_stats_header_alert))
|
||||||
# then the actual stats values
|
# then the actual stats values
|
||||||
while len(alerts) == 0:
|
while len(alerts) == 0:
|
||||||
|
@ -558,12 +562,6 @@ class test_session(unittest.TestCase):
|
||||||
s.wait_for_alert(1000)
|
s.wait_for_alert(1000)
|
||||||
alerts = s.pop_alerts()
|
alerts = s.pop_alerts()
|
||||||
a = alerts.pop(0)
|
a = alerts.pop(0)
|
||||||
self.assertTrue(isinstance(a, lt.session_stats_header_alert))
|
|
||||||
print(a.message())
|
|
||||||
while len(alerts) == 0:
|
|
||||||
s.wait_for_alert(1000)
|
|
||||||
alerts = s.pop_alerts()
|
|
||||||
a = alerts.pop(0)
|
|
||||||
self.assertTrue(isinstance(a, lt.dht_stats_alert))
|
self.assertTrue(isinstance(a, lt.dht_stats_alert))
|
||||||
self.assertTrue(isinstance(a.active_requests, list))
|
self.assertTrue(isinstance(a.active_requests, list))
|
||||||
self.assertTrue(isinstance(a.routing_table, list))
|
self.assertTrue(isinstance(a.routing_table, list))
|
||||||
|
|
|
@ -2755,8 +2755,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
aux::allocation_slot m_v6_nodes_idx;
|
aux::allocation_slot m_v6_nodes_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The session_stats_header alert is posted during the init of the
|
// The session_stats_header alert is posted the first time
|
||||||
// session thread.
|
// post_session_stats() is called
|
||||||
//
|
//
|
||||||
// the ``message()`` member function returns a string representation of the
|
// the ``message()`` member function returns a string representation of the
|
||||||
// header that properly match the stats values string returned in
|
// header that properly match the stats values string returned in
|
||||||
|
|
|
@ -721,7 +721,11 @@ namespace aux {
|
||||||
{ return &m_ssl_utp_socket_manager; }
|
{ return &m_ssl_utp_socket_manager; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void inc_boost_connections() override { ++m_boost_connections; }
|
void inc_boost_connections() override
|
||||||
|
{
|
||||||
|
++m_boost_connections;
|
||||||
|
m_stats_counters.inc_stats_counter(counters::boost_connection_attempts);
|
||||||
|
}
|
||||||
|
|
||||||
// the settings for the client
|
// the settings for the client
|
||||||
aux::session_settings m_settings;
|
aux::session_settings m_settings;
|
||||||
|
@ -1297,6 +1301,10 @@ namespace aux {
|
||||||
|
|
||||||
// is true if the session is paused
|
// is true if the session is paused
|
||||||
bool m_paused = false;
|
bool m_paused = false;
|
||||||
|
|
||||||
|
// set to true the first time post_session_stats() is
|
||||||
|
// called and we post the headers alert
|
||||||
|
bool m_posted_stats_header = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
|
|
@ -116,6 +116,18 @@ namespace libtorrent {
|
||||||
// the number of iterations over the peer list when finding
|
// the number of iterations over the peer list when finding
|
||||||
// a connect candidate
|
// a connect candidate
|
||||||
connection_attempt_loops,
|
connection_attempt_loops,
|
||||||
|
|
||||||
|
// the number of peer connection attempts made as high
|
||||||
|
// priority connections for new torrents
|
||||||
|
boost_connection_attempts,
|
||||||
|
|
||||||
|
// calls to torrent::connect_to_peer() that failed
|
||||||
|
missed_connection_attempts,
|
||||||
|
|
||||||
|
// calls to peer_list::connect_one_peer() resulting in
|
||||||
|
// no peer candidate being found
|
||||||
|
no_peer_connection_attempts,
|
||||||
|
|
||||||
// successful incoming connections (not rejected for any reason)
|
// successful incoming connections (not rejected for any reason)
|
||||||
incoming_connections,
|
incoming_connections,
|
||||||
|
|
||||||
|
|
|
@ -552,8 +552,6 @@ namespace aux {
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
session_log(" *** session thread init");
|
session_log(" *** session thread init");
|
||||||
#endif
|
#endif
|
||||||
if (m_alerts.should_post<session_stats_header_alert>())
|
|
||||||
m_alerts.emplace_alert<session_stats_header_alert>();
|
|
||||||
|
|
||||||
// this is where we should set up all async operations. This
|
// this is where we should set up all async operations. This
|
||||||
// is called from within the network thread as opposed to the
|
// is called from within the network thread as opposed to the
|
||||||
|
@ -4622,6 +4620,11 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::post_session_stats()
|
void session_impl::post_session_stats()
|
||||||
{
|
{
|
||||||
|
if (!m_posted_stats_header)
|
||||||
|
{
|
||||||
|
m_posted_stats_header = true;
|
||||||
|
m_alerts.emplace_alert<session_stats_header_alert>();
|
||||||
|
}
|
||||||
m_disk_thread.update_stats_counters(m_stats_counters);
|
m_disk_thread.update_stats_counters(m_stats_counters);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
|
|
@ -123,6 +123,9 @@ namespace {
|
||||||
|
|
||||||
METRIC(peer, connection_attempts)
|
METRIC(peer, connection_attempts)
|
||||||
METRIC(peer, connection_attempt_loops)
|
METRIC(peer, connection_attempt_loops)
|
||||||
|
METRIC(peer, boost_connection_attempts)
|
||||||
|
METRIC(peer, missed_connection_attempts)
|
||||||
|
METRIC(peer, no_peer_connection_attempts)
|
||||||
METRIC(peer, incoming_connections)
|
METRIC(peer, incoming_connections)
|
||||||
|
|
||||||
// the number of peer connections for each kind of socket.
|
// the number of peer connections for each kind of socket.
|
||||||
|
|
|
@ -10055,12 +10055,14 @@ bool is_downloading_state(int const st)
|
||||||
|
|
||||||
if (p == nullptr)
|
if (p == nullptr)
|
||||||
{
|
{
|
||||||
|
m_stats_counters.inc_stats_counter(counters::no_peer_connection_attempts);
|
||||||
update_want_peers();
|
update_want_peers();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connect_to_peer(p))
|
if (!connect_to_peer(p))
|
||||||
{
|
{
|
||||||
|
m_stats_counters.inc_stats_counter(counters::missed_connection_attempts);
|
||||||
m_peer_list->inc_failcount(p);
|
m_peer_list->inc_failcount(p);
|
||||||
update_want_peers();
|
update_want_peers();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -45,9 +45,11 @@ output_dir = 'session_stats_report'
|
||||||
|
|
||||||
stat = open(sys.argv[1])
|
stat = open(sys.argv[1])
|
||||||
line = stat.readline()
|
line = stat.readline()
|
||||||
|
print('looking for stats header')
|
||||||
while 'session stats header:' not in line:
|
while 'session stats header:' not in line:
|
||||||
line = stat.readline()
|
line = stat.readline()
|
||||||
|
|
||||||
|
print('found')
|
||||||
keys = line.split('session stats header:')[1].strip().split(', ')
|
keys = line.split('session stats header:')[1].strip().split(', ')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -129,7 +131,7 @@ for i in range(0, 6):
|
||||||
def plot_fun(script):
|
def plot_fun(script):
|
||||||
ret = os.system('gnuplot "%s" 2>/dev/null' % script)
|
ret = os.system('gnuplot "%s" 2>/dev/null' % script)
|
||||||
if ret != 0 and ret != 256:
|
if ret != 0 and ret != 256:
|
||||||
print('system: %d\n' % ret)
|
print('gnuplot failed: %d\n' % ret)
|
||||||
raise Exception("abort")
|
raise Exception("abort")
|
||||||
|
|
||||||
sys.stdout.write('.')
|
sys.stdout.write('.')
|
||||||
|
@ -333,7 +335,8 @@ reports = [
|
||||||
'peer.num_peers_connected', 'peer.num_peers_half_open'], {'type': stacked}),
|
'peer.num_peers_connected', 'peer.num_peers_half_open'], {'type': stacked}),
|
||||||
('peers_max', 'num', '', 'num connected peers', ['peer.num_peers_connected', 'peer.num_peers_half_open']),
|
('peers_max', 'num', '', 'num connected peers', ['peer.num_peers_connected', 'peer.num_peers_half_open']),
|
||||||
('peer_churn', 'num', '', 'connecting and disconnecting peers',
|
('peer_churn', 'num', '', 'connecting and disconnecting peers',
|
||||||
['peer.num_peers_half_open', 'peer.connection_attempts']),
|
['peer.num_peers_half_open', 'peer.connection_attempts', 'peer.boost_connection_attempts',
|
||||||
|
'peer.missed_connection_attempts', 'peer.no_peer_connection_attempts']),
|
||||||
('new_peers', 'num', '', '', ['peer.incoming_connections', 'peer.connection_attempts']),
|
('new_peers', 'num', '', '', ['peer.incoming_connections', 'peer.connection_attempts']),
|
||||||
('connection_attempts', 'num', '', '', ['peer.connection_attempt_loops', 'peer.connection_attempts']),
|
('connection_attempts', 'num', '', '', ['peer.connection_attempt_loops', 'peer.connection_attempts']),
|
||||||
('pieces', 'num', '', 'number completed pieces', [
|
('pieces', 'num', '', 'number completed pieces', [
|
||||||
|
@ -536,9 +539,6 @@ reports = [
|
||||||
'disk.arc_mfu_ghost_size' \
|
'disk.arc_mfu_ghost_size' \
|
||||||
], {'allow-negative': True}),
|
], {'allow-negative': True}),
|
||||||
|
|
||||||
('torrent churn', 'num torrents', '', '', ['ses.num_loaded_torrents', 'ses.num_pinned_torrents']),
|
|
||||||
('pinned torrents', 'num torrents', '', '', ['ses.num_pinned_torrents']),
|
|
||||||
('loaded torrents', 'num torrents', '', '', ['ses.num_loaded_torrents', 'ses.num_pinned_torrents']),
|
|
||||||
('request latency', 'us', '', 'latency from receiving requests to sending response', ['disk.request_latency']),
|
('request latency', 'us', '', 'latency from receiving requests to sending response', ['disk.request_latency']),
|
||||||
('incoming messages', 'num', '', 'number of received bittorrent messages, by type', [ \
|
('incoming messages', 'num', '', 'number of received bittorrent messages, by type', [ \
|
||||||
'ses.num_incoming_choke', \
|
'ses.num_incoming_choke', \
|
||||||
|
@ -639,7 +639,7 @@ g = 0
|
||||||
generations = []
|
generations = []
|
||||||
scripts = []
|
scripts = []
|
||||||
|
|
||||||
print('[%s] %04d\r[' % (' ' * len(reports), g), end=' ')
|
print('[%s] %04d\r[' % (' ' * len(reports), g), end='')
|
||||||
for i in reports:
|
for i in reports:
|
||||||
try:
|
try:
|
||||||
options = i[5]
|
options = i[5]
|
||||||
|
|
Loading…
Reference in New Issue