From 8b6522a7639eb7b3f0a20322c41941e3e5912ff4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 17 Oct 2011 06:54:02 +0000 Subject: [PATCH] log buffer sizes passed to read() and write() at the socket layer (to identify performane problems) --- include/libtorrent/aux_/session_impl.hpp | 4 ++++ parse_session_stats.py | 2 ++ src/peer_connection.cpp | 12 ++++++++++++ src/session_impl.cpp | 14 ++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index c388c37e7..32dc68114 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -959,6 +959,10 @@ namespace libtorrent max_messages }; int m_num_messages[max_messages]; + // 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, + // 16384, 32768, 65536, 131072, 262144, 524288, 1048576 + int m_send_buffer_sizes[18]; + int m_recv_buffer_sizes[18]; #endif // each second tick the timer takes a little diff --git a/parse_session_stats.py b/parse_session_stats.py index 737ad7841..25e49c1c4 100755 --- a/parse_session_stats.py +++ b/parse_session_stats.py @@ -154,6 +154,8 @@ reports = [ 'read_counter', 'write_counter', 'tick_counter', 'lsd_counter', \ 'lsd_peer_counter', 'udp_counter', 'accept_counter', 'disk_queue_counter', \ 'disk_read_counter', 'disk_write_counter']), + ('send_buffer_sizes', 'num', '', '', ['up 8', 'up 16', 'up 32', 'up 64', 'up 128', 'up 256', 'up 512', 'up 1024', 'up 2048', 'up 4096', 'up 8192', 'up 16384', 'up 32768', 'up 65536', 'up 131072', 'up 262144']), + ('recv_buffer_sizes', 'num', '', '', ['down 8', 'down 16', 'down 32', 'down 64', 'down 128', 'down 256', 'down 512', 'down 1024', 'down 2048', 'down 4096', 'down 8192', 'down 16384', 'down 32768', 'down 65536', 'down 131072', 'down 262144']), # ('absolute_waste', 'num', '', ['failed bytes', 'redundant bytes', 'download rate']), #somewhat uninteresting stats diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index f89ee9c7e..4f2d52d69 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5028,6 +5028,12 @@ namespace libtorrent { #ifdef TORRENT_STATS ++m_ses.m_num_messages[aux::session_impl::on_read_counter]; + int size = 8; + int index = 0; + while (bytes_transferred > size) { size <<= 1; ++index; } + int num_max = sizeof(m_ses.m_recv_buffer_sizes)/sizeof(m_ses.m_recv_buffer_sizes[0]); + if (index >= num_max) index = num_max - 1; + ++m_ses.m_recv_buffer_sizes[index]; #endif TORRENT_ASSERT(m_ses.is_network_thread()); @@ -5370,6 +5376,12 @@ namespace libtorrent { #ifdef TORRENT_STATS ++m_ses.m_num_messages[aux::session_impl::on_write_counter]; + int size = 8; + int index = 0; + while (bytes_transferred > size) { size <<= 1; ++index; } + int num_max = sizeof(m_ses.m_send_buffer_sizes)/sizeof(m_ses.m_send_buffer_sizes[0]); + if (index >= num_max) index = num_max - 1; + ++m_ses.m_send_buffer_sizes[index]; #endif TORRENT_ASSERT(m_ses.is_network_thread()); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f01b4fc50..6df22a973 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1056,6 +1056,8 @@ namespace aux { ":disk_queue_counter" ":disk_read_counter" ":disk_write_counter" + ":up 8:up 16:up 32:up 64:up 128:up 256:up 512:up 1024:up 2048:up 4096:up 8192:up 16384:up 32768:up 65536:up 131072:up 262144:up 524288:up 1048576" + ":down 8:down 16:down 32:down 64:down 128:down 256:down 512:down 1024:down 2048:down 4096:down 8192:down 16384:down 32768:down 65536:down 131072:down 262144:down 524288:down 1048576" "\n\n", m_stats_logger); } #endif @@ -3239,6 +3241,8 @@ namespace aux { m_banned_for_hash_failure = 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)); } void session_impl::print_log_line(int tick_interval_ms, ptime now) @@ -3547,6 +3551,16 @@ namespace aux { { STAT_LOG(d, m_num_messages[i]); } + int num_max = sizeof(m_send_buffer_sizes)/sizeof(m_send_buffer_sizes[0]); + for (int i = 0; i < num_max; ++i) + { + STAT_LOG(d, m_send_buffer_sizes[i]); + } + num_max = sizeof(m_recv_buffer_sizes)/sizeof(m_recv_buffer_sizes[0]); + for (int i = 0; i < num_max; ++i) + { + STAT_LOG(d, m_recv_buffer_sizes[i]); + } fprintf(m_stats_logger, "\n");