log VM stats alongside the session stats
This commit is contained in:
parent
1e4a3d990c
commit
90d8030269
|
@ -94,6 +94,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/asio/ssl/context.hpp>
|
#include <boost/asio/ssl/context.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TORRENT_STATS && defined __MACH__
|
||||||
|
#include <mach/vm_statistics.h>
|
||||||
|
#include <mach/mach_init.h>
|
||||||
|
#include <mach/host_info.h>
|
||||||
|
#include <mach/mach_host.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -116,6 +123,19 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
struct session_impl;
|
struct session_impl;
|
||||||
|
|
||||||
|
#if defined TORRENT_STATS && !defined __MACH__
|
||||||
|
struct vm_statistics_data_t
|
||||||
|
{
|
||||||
|
boost::uint64_t active_count;
|
||||||
|
boost::uint64_t inactive_count;
|
||||||
|
boost::uint64_t wire_count;
|
||||||
|
boost::uint64_t free_count;
|
||||||
|
boost::uint64_t pageins;
|
||||||
|
boost::uint64_t pageouts;
|
||||||
|
boost::uint64_t faults;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
struct tracker_logger;
|
struct tracker_logger;
|
||||||
#endif
|
#endif
|
||||||
|
@ -912,6 +932,7 @@ namespace libtorrent
|
||||||
int m_connection_attempts;
|
int m_connection_attempts;
|
||||||
int m_num_banned_peers;
|
int m_num_banned_peers;
|
||||||
int m_banned_for_hash_failure;
|
int m_banned_for_hash_failure;
|
||||||
|
vm_statistics_data_t m_last_vm_stat;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// each second tick the timer takes a little
|
// each second tick the timer takes a little
|
||||||
|
|
|
@ -122,7 +122,10 @@ reports = [
|
||||||
('disk_queue', 'number of queued disk jobs', '', 'queued disk jobs', ['disk queue size', 'disk read queue size', 'read job queue size limit']),
|
('disk_queue', 'number of queued disk jobs', '', 'queued disk jobs', ['disk queue size', 'disk read queue size', 'read job queue size limit']),
|
||||||
('disk_iops', 'operations/s', '', 'number of disk operations per second', ['read ops/s', 'write ops/s']),
|
('disk_iops', 'operations/s', '', 'number of disk operations per second', ['read ops/s', 'write ops/s']),
|
||||||
('mixed mode', 'rate', 'B/s', 'rates by transport protocol', ['TCP up rate','TCP down rate','uTP up rate','uTP down rate','TCP up limit','TCP down limit']),
|
('mixed mode', 'rate', 'B/s', 'rates by transport protocol', ['TCP up rate','TCP down rate','uTP up rate','uTP down rate','TCP up limit','TCP down limit']),
|
||||||
('uTP delay', 'buffer delay', 's', 'network delays measured by uTP', ['uTP peak send delay','uTP avg send delay']),
|
('uTP delay', 'buffering delay', 's', 'network delays measured by uTP', ['uTP peak send delay','uTP avg send delay']),
|
||||||
|
('system memory', '', '', 'virtual memory page count', ['active resident pages', 'inactive resident pages', 'pinned resident pages', 'free pages']),
|
||||||
|
('memory paging', '', '', 'vm disk activity', ['pageins', 'pageouts']),
|
||||||
|
('page faults', '', '', '', ['page faults']),
|
||||||
# ('absolute_waste', 'num', '', ['failed bytes', 'redundant bytes', 'download rate']),
|
# ('absolute_waste', 'num', '', ['failed bytes', 'redundant bytes', 'download rate']),
|
||||||
|
|
||||||
#somewhat uninteresting stats
|
#somewhat uninteresting stats
|
||||||
|
|
|
@ -810,6 +810,11 @@ namespace aux {
|
||||||
m_stats_logger = 0;
|
m_stats_logger = 0;
|
||||||
m_log_seq = 0;
|
m_log_seq = 0;
|
||||||
m_stats_logging_enabled = true;
|
m_stats_logging_enabled = true;
|
||||||
|
|
||||||
|
memset(&m_last_cache_status, 0, sizeof(m_last_cache_status));
|
||||||
|
extern void get_vm_stats(vm_statistics_data_t* vm_stat);
|
||||||
|
get_vm_stats(&m_last_vm_stat);
|
||||||
|
|
||||||
reset_stat_counters();
|
reset_stat_counters();
|
||||||
rotate_stats_log();
|
rotate_stats_log();
|
||||||
#endif
|
#endif
|
||||||
|
@ -969,6 +974,13 @@ namespace aux {
|
||||||
":uTP avg send delay"
|
":uTP avg send delay"
|
||||||
":read ops/s"
|
":read ops/s"
|
||||||
":write ops/s"
|
":write ops/s"
|
||||||
|
":active resident pages"
|
||||||
|
":inactive resident pages"
|
||||||
|
":pinned resident pages"
|
||||||
|
":free pages"
|
||||||
|
":pageins"
|
||||||
|
":pageouts"
|
||||||
|
":page faults"
|
||||||
"\n\n", m_stats_logger);
|
"\n\n", m_stats_logger);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3049,6 +3061,21 @@ namespace aux {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_STATS
|
#ifdef TORRENT_STATS
|
||||||
|
|
||||||
|
void get_vm_stats(vm_statistics_data_t* vm_stat)
|
||||||
|
{
|
||||||
|
memset(vm_stat, 0, sizeof(*vm_stat));
|
||||||
|
#if defined __MACH__
|
||||||
|
mach_port_t host_port = mach_host_self();
|
||||||
|
mach_msg_type_number_t host_count = HOST_VM_INFO_COUNT;
|
||||||
|
kern_return_t error = host_statistics(host_port, HOST_VM_INFO,
|
||||||
|
(host_info_t)vm_stat, &host_count);
|
||||||
|
#elif defined TORRENT_LINUX
|
||||||
|
// TODO: read straight from /proc/meminfo ?
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void session_impl::enable_stats_logging(bool s)
|
void session_impl::enable_stats_logging(bool s)
|
||||||
{
|
{
|
||||||
if (m_stats_logging_enabled == s) return;
|
if (m_stats_logging_enabled == s) return;
|
||||||
|
@ -3236,6 +3263,10 @@ namespace aux {
|
||||||
if (now - m_last_log_rotation > hours(1))
|
if (now - m_last_log_rotation > hours(1))
|
||||||
rotate_stats_log();
|
rotate_stats_log();
|
||||||
|
|
||||||
|
// system memory stats
|
||||||
|
vm_statistics_data_t vm_stat;
|
||||||
|
get_vm_stats(&vm_stat);
|
||||||
|
|
||||||
if (m_stats_logger)
|
if (m_stats_logger)
|
||||||
{
|
{
|
||||||
cache_status cs = m_disk_thread.status();
|
cache_status cs = m_disk_thread.status();
|
||||||
|
@ -3356,11 +3387,21 @@ namespace aux {
|
||||||
STAT_LOG(f, float(utp_num_delay_sockets ? float(utp_send_delay_sum) / float(utp_num_delay_sockets) : 0) / 1000000.f);
|
STAT_LOG(f, float(utp_num_delay_sockets ? float(utp_send_delay_sum) / float(utp_num_delay_sockets) : 0) / 1000000.f);
|
||||||
STAT_LOG(f, float(cs.reads - m_last_cache_status.reads) * 1000.0 / float(tick_interval_ms));
|
STAT_LOG(f, float(cs.reads - m_last_cache_status.reads) * 1000.0 / float(tick_interval_ms));
|
||||||
STAT_LOG(f, float(cs.writes - m_last_cache_status.writes) * 1000.0 / float(tick_interval_ms));
|
STAT_LOG(f, float(cs.writes - m_last_cache_status.writes) * 1000.0 / float(tick_interval_ms));
|
||||||
|
|
||||||
|
STAT_LOG(d, int(vm_stat.active_count));
|
||||||
|
STAT_LOG(d, int(vm_stat.inactive_count));
|
||||||
|
STAT_LOG(d, int(vm_stat.wire_count));
|
||||||
|
STAT_LOG(d, int(vm_stat.free_count));
|
||||||
|
STAT_LOG(d, int(vm_stat.pageins - m_last_vm_stat.pageins));
|
||||||
|
STAT_LOG(d, int(vm_stat.pageouts - m_last_vm_stat.pageouts));
|
||||||
|
STAT_LOG(d, int(vm_stat.faults - m_last_vm_stat.faults));
|
||||||
|
|
||||||
fprintf(m_stats_logger, "\n");
|
fprintf(m_stats_logger, "\n");
|
||||||
|
|
||||||
#undef STAT_LOG
|
#undef STAT_LOG
|
||||||
|
|
||||||
m_last_cache_status = cs;
|
m_last_cache_status = cs;
|
||||||
|
m_last_vm_stat = vm_stat;
|
||||||
m_last_failed = m_total_failed_bytes;
|
m_last_failed = m_total_failed_bytes;
|
||||||
m_last_redundant = m_total_redundant_bytes;
|
m_last_redundant = m_total_redundant_bytes;
|
||||||
m_last_uploaded = m_stat.total_upload();
|
m_last_uploaded = m_stat.total_upload();
|
||||||
|
|
Loading…
Reference in New Issue