back ported simplification of stats logging code from aio branch

This commit is contained in:
Arvid Norberg 2011-06-26 18:43:23 +00:00
parent abb015e3de
commit 2e70f92003
1 changed files with 116 additions and 123 deletions

View File

@ -3240,129 +3240,122 @@ namespace aux {
int total_job_time = cs.cumulative_job_time == 0 ? 1 : cs.cumulative_job_time;
fprintf(m_stats_logger
, "%f\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t"
"%f\t%f\t%f\t%f\t%f\t%f\t%d\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%f\t%f\t%f\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%f\t%f\t"
"%f\t%f\t%d\t%f\t%d\t%f\t%f\t%d\t%d\t%d\t"
"%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%f\t%f\n"
, total_milliseconds(now - m_last_log_rotation) / 1000.f
, int(m_stat.total_upload() - m_last_uploaded)
, int(m_stat.total_download() - m_last_downloaded)
, downloading_torrents
, seeding_torrents
, num_complete_connections
, num_half_open
, m_disk_thread.disk_allocations()
, num_peers
, logging_allocator::allocations
, logging_allocator::allocated_bytes
, checking_torrents
, stopped_torrents
, upload_only_torrents
, m_upload_rate.queue_size()
, m_download_rate.queue_size()
, m_disk_queues[peer_connection::upload_channel]
, m_disk_queues[peer_connection::download_channel]
, m_stat.upload_rate()
, m_stat.download_rate()
, int(m_disk_thread.queue_buffer_size())
, peer_dl_rate_buckets[0]
, peer_dl_rate_buckets[1]
, peer_dl_rate_buckets[2]
, peer_dl_rate_buckets[3]
, peer_dl_rate_buckets[4]
, peer_dl_rate_buckets[5]
, peer_dl_rate_buckets[6]
, peer_ul_rate_buckets[0]
, peer_ul_rate_buckets[1]
, peer_ul_rate_buckets[2]
, peer_ul_rate_buckets[3]
, peer_ul_rate_buckets[4]
, peer_ul_rate_buckets[5]
, peer_ul_rate_buckets[6]
, m_error_peers
, peers_down_interesting
, peers_down_unchoked
, peers_down_requests
, peers_up_interested
, peers_up_unchoked
, peers_up_requests
, m_disconnected_peers
, m_eof_peers
, m_connreset_peers
, outstanding_requests
, outstanding_end_game_requests
, outstanding_write_blocks
, m_end_game_piece_picker_blocks
, m_piece_picker_blocks
, m_piece_picks
, m_reject_piece_picks
, m_unchoke_piece_picks
, m_incoming_redundant_piece_picks
, m_incoming_piece_picks
, m_end_game_piece_picks
, m_snubbed_piece_picks
, m_connect_timeouts
, m_uninteresting_peers
, m_timeout_peers
, (float(m_total_failed_bytes) * 100.f / m_stat.total_payload_download())
, (float(m_total_redundant_bytes) * 100.f / m_stat.total_payload_download())
, (float(m_stat.total_protocol_download()) * 100.f / m_stat.total_download())
, float(cs.average_read_time) / 1000000.f
, float(cs.average_write_time) / 1000000.f
, float(cs.average_queue_time) / 1000000.f
, int(cs.job_queue_length)
, int(cs.queued_bytes)
, int(cs.blocks_read_hit - m_last_cache_status.blocks_read_hit)
, int(cs.blocks_read - m_last_cache_status.blocks_read)
, int(cs.blocks_written - m_last_cache_status.blocks_written)
, int(m_total_failed_bytes - m_last_failed)
, int(m_total_redundant_bytes - m_last_redundant)
, error_torrents
, cs.read_cache_size
, cs.cache_size
, cs.total_used_buffers
, float(cs.average_hash_time) / 1000000.f
, float(cs.average_job_time) / 1000000.f
, float(cs.average_sort_time) / 1000000.f
, m_connection_attempts
, m_num_banned_peers
, m_banned_for_hash_failure
, m_settings.cache_size
, m_settings.connections_limit
, connect_candidates
, int(m_settings.max_queued_disk_bytes)
, low_watermark
, float(cs.cumulative_read_time * 100.f / total_job_time)
, float(cs.cumulative_write_time * 100.f / total_job_time)
, float(cs.cumulative_hash_time * 100.f / total_job_time)
, float(cs.cumulative_sort_time * 100.f / total_job_time)
, int(cs.total_read_back - m_last_cache_status.total_read_back)
, float(cs.total_read_back * 100.f / (cs.blocks_written == 0 ? 1: cs.blocks_written))
, cs.read_queue_size
, float(tick_interval_ms) / 1000.f
, float(m_tick_residual) / 1000.f
, m_allowed_upload_slots
, m_settings.unchoke_slots_limit * 2
, m_stat.low_pass_upload_rate()
, m_stat.low_pass_download_rate()
, num_end_game_peers
, tcp_up_rate
, tcp_down_rate
, int(m_tcp_upload_channel.throttle())
, int(m_tcp_download_channel.throttle())
, utp_up_rate
, utp_down_rate
, float(utp_peak_send_delay) / 1000000.f
, float(utp_num_delay_sockets ? float(utp_send_delay_sum) / float(utp_num_delay_sockets) : 0) / 1000000.f
);
#define STAT_LOG(type, val) fprintf(m_stats_logger, "%" #type "\t", val)
STAT_LOG(d, total_milliseconds(now - m_last_log_rotation) / 1000.f);
STAT_LOG(d, int(m_stat.total_upload() - m_last_uploaded));
STAT_LOG(d, int(m_stat.total_download() - m_last_downloaded));
STAT_LOG(d, downloading_torrents);
STAT_LOG(d, seeding_torrents);
STAT_LOG(d, num_complete_connections);
STAT_LOG(d, num_half_open);
STAT_LOG(d, m_disk_thread.disk_allocations());
STAT_LOG(d, num_peers);
STAT_LOG(d, logging_allocator::allocations);
STAT_LOG(d, logging_allocator::allocated_bytes);
STAT_LOG(d, checking_torrents);
STAT_LOG(d, stopped_torrents);
STAT_LOG(d, upload_only_torrents);
STAT_LOG(d, m_upload_rate.queue_size());
STAT_LOG(d, m_download_rate.queue_size());
STAT_LOG(d, m_disk_queues[peer_connection::upload_channel]);
STAT_LOG(d, m_disk_queues[peer_connection::download_channel]);
STAT_LOG(d, m_stat.upload_rate());
STAT_LOG(d, m_stat.download_rate());
STAT_LOG(d, int(m_disk_thread.queue_buffer_size()));
STAT_LOG(d, peer_dl_rate_buckets[0]);
STAT_LOG(d, peer_dl_rate_buckets[1]);
STAT_LOG(d, peer_dl_rate_buckets[2]);
STAT_LOG(d, peer_dl_rate_buckets[3]);
STAT_LOG(d, peer_dl_rate_buckets[4]);
STAT_LOG(d, peer_dl_rate_buckets[5]);
STAT_LOG(d, peer_dl_rate_buckets[6]);
STAT_LOG(d, peer_ul_rate_buckets[0]);
STAT_LOG(d, peer_ul_rate_buckets[1]);
STAT_LOG(d, peer_ul_rate_buckets[2]);
STAT_LOG(d, peer_ul_rate_buckets[3]);
STAT_LOG(d, peer_ul_rate_buckets[4]);
STAT_LOG(d, peer_ul_rate_buckets[5]);
STAT_LOG(d, peer_ul_rate_buckets[6]);
STAT_LOG(d, m_error_peers);
STAT_LOG(d, peers_down_interesting);
STAT_LOG(d, peers_down_unchoked);
STAT_LOG(d, peers_down_requests);
STAT_LOG(d, peers_up_interested);
STAT_LOG(d, peers_up_unchoked);
STAT_LOG(d, peers_up_requests);
STAT_LOG(d, m_disconnected_peers);
STAT_LOG(d, m_eof_peers);
STAT_LOG(d, m_connreset_peers);
STAT_LOG(d, outstanding_requests);
STAT_LOG(d, outstanding_end_game_requests);
STAT_LOG(d, outstanding_write_blocks);
STAT_LOG(d, m_end_game_piece_picker_blocks);
STAT_LOG(d, m_piece_picker_blocks);
STAT_LOG(d, m_piece_picks);
STAT_LOG(d, m_reject_piece_picks);
STAT_LOG(d, m_unchoke_piece_picks);
STAT_LOG(d, m_incoming_redundant_piece_picks);
STAT_LOG(d, m_incoming_piece_picks);
STAT_LOG(d, m_end_game_piece_picks);
STAT_LOG(d, m_snubbed_piece_picks);
STAT_LOG(d, m_connect_timeouts);
STAT_LOG(d, m_uninteresting_peers);
STAT_LOG(d, m_timeout_peers);
STAT_LOG(f, (float(m_total_failed_bytes) * 100.f / m_stat.total_payload_download()));
STAT_LOG(f, (float(m_total_redundant_bytes) * 100.f / m_stat.total_payload_download()));
STAT_LOG(f, (float(m_stat.total_protocol_download()) * 100.f / m_stat.total_download()));
STAT_LOG(f, float(cs.average_read_time) / 1000000.f);
STAT_LOG(f, float(cs.average_write_time) / 1000000.f);
STAT_LOG(f, float(cs.average_queue_time) / 1000000.f);
STAT_LOG(d, int(cs.job_queue_length));
STAT_LOG(d, int(cs.queued_bytes));
STAT_LOG(d, int(cs.blocks_read_hit - m_last_cache_status.blocks_read_hit));
STAT_LOG(d, int(cs.blocks_read - m_last_cache_status.blocks_read));
STAT_LOG(d, int(cs.blocks_written - m_last_cache_status.blocks_written));
STAT_LOG(d, int(m_total_failed_bytes - m_last_failed));
STAT_LOG(d, int(m_total_redundant_bytes - m_last_redundant));
STAT_LOG(d, error_torrents);
STAT_LOG(d, cs.read_cache_size);
STAT_LOG(d, cs.cache_size);
STAT_LOG(d, cs.total_used_buffers);
STAT_LOG(f, float(cs.average_hash_time) / 1000000.f);
STAT_LOG(f, float(cs.average_job_time) / 1000000.f);
STAT_LOG(f, float(cs.average_sort_time) / 1000000.f);
STAT_LOG(d, m_connection_attempts);
STAT_LOG(d, m_num_banned_peers);
STAT_LOG(d, m_banned_for_hash_failure);
STAT_LOG(d, m_settings.cache_size);
STAT_LOG(d, m_settings.connections_limit);
STAT_LOG(d, connect_candidates);
STAT_LOG(d, int(m_settings.max_queued_disk_bytes));
STAT_LOG(d, low_watermark);
STAT_LOG(f, float(cs.cumulative_read_time * 100.f / total_job_time));
STAT_LOG(f, float(cs.cumulative_write_time * 100.f / total_job_time));
STAT_LOG(f, float(cs.cumulative_hash_time * 100.f / total_job_time));
STAT_LOG(f, float(cs.cumulative_sort_time * 100.f / total_job_time));
STAT_LOG(d, int(cs.total_read_back - m_last_cache_status.total_read_back));
STAT_LOG(f, float(cs.total_read_back * 100.f / (cs.blocks_written == 0 ? 1: cs.blocks_written)));
STAT_LOG(d, cs.read_queue_size);
STAT_LOG(f, float(tick_interval_ms) / 1000.f);
STAT_LOG(f, float(m_tick_residual) / 1000.f);
STAT_LOG(d, m_allowed_upload_slots);
STAT_LOG(d, m_settings.unchoke_slots_limit * 2);
STAT_LOG(d, m_stat.low_pass_upload_rate());
STAT_LOG(d, m_stat.low_pass_download_rate());
STAT_LOG(d, num_end_game_peers);
STAT_LOG(d, tcp_up_rate);
STAT_LOG(d, tcp_down_rate);
STAT_LOG(d, int(m_tcp_upload_channel.throttle()));
STAT_LOG(d, int(m_tcp_download_channel.throttle()));
STAT_LOG(d, utp_up_rate);
STAT_LOG(d, utp_down_rate);
STAT_LOG(f, float(utp_peak_send_delay) / 1000000.f);
STAT_LOG(f, float(utp_num_delay_sockets ? float(utp_send_delay_sum) / float(utp_num_delay_sockets) : 0) / 1000000.f);
fprintf(m_stats_logger, "\n");
#undef STAT_LOG
m_last_cache_status = cs;
m_last_failed = m_total_failed_bytes;
m_last_redundant = m_total_redundant_bytes;