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