From 47efb608ab4526486cbca6159b48cf05658497aa Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sat, 9 Apr 2011 13:50:30 +0000 Subject: [PATCH] * Added more instrumentation. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1204 e378c898-3ddf-0310-93e7-cc216c733640 --- doc/log_stats.plot | 58 ++++++++++++++++++++++++++++---------------- src/command_local.cc | 17 ++++++++++++- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/doc/log_stats.plot b/doc/log_stats.plot index f3d416a0..f80707ae 100644 --- a/doc/log_stats.plot +++ b/doc/log_stats.plot @@ -1,40 +1,56 @@ #/bin/bash gnuplot << EOF -# $system.time_seconds= +# 1) $system.time_seconds= # -# $throttle.global_up.rate= -# $throttle.global_up.total= -# $throttle.global_down.rate= -# $throttle.global_down.total= +# 2) $throttle.global_up.rate= +# 3) $throttle.global_up.total= +# 4) $throttle.global_down.rate= +# 5) $throttle.global_down.total= # -# $throttle.unchoked_uploads= -# $throttle.unchoked_downloads= -# $pieces.memory.current= +# 6) $throttle.unchoked_uploads= +# 7) $throttle.unchoked_downloads= +# 8) $view.size=active +# 9) $pieces.memory.current= +# 10) $pieces.memory.sync_queue= +# 11) $pieces.stats.total_size= # -# schedule = log_stats,5,10,((execute,log_rtorrent.sh,((cat,/foo/bandwidth_stats.,((system.pid)))),((system.time_seconds)),((throttle.global_up.rate)),((throttle.global_up.total)),((throttle.global_down.rate)),((throttle.global_down.total)),((throttle.unchoked_uploads)),((throttle.unchoked_downloads)),((pieces.memory.current)))) +# log.libtorrent = mincore_stats,(cat,"/foo/mincore_stats.",(system.pid)) +# schedule = log_stats,5,10,((execute,log_rtorrent.sh,((cat,/foo/bandwidth_stats.,((system.pid)))),((system.time_seconds)),((throttle.global_up.rate)),((throttle.global_up.total)),((throttle.global_down.rate)),((throttle.global_down.total)),((throttle.unchoked_uploads)),((throttle.unchoked_downloads)),((view.size,active)),((pieces.memory.current)),((pieces.memory.sync_queue)),((pieces.stats.total_size)))) set terminal png -set output "output.png" set xdata time set timefmt "%s" set format x "%H:%M" +set format y "%.0s %cb" +set format y2 "%.0f" +set y2tics +set autoscale x #set multiplot -plot "$1" using 1:2 smooth bezier with lines title 'Upload rate',\ - "$1" using 1:4 smooth bezier with lines title 'Download rate',\ - "$1" using 1:6 smooth bezier with lines title 'Upload unchoked' axis x1y2,\ - "$1" using 1:7 smooth bezier with lines title 'Download unchoked' axis x1y2 +grab(x)=(xmax)?max=x:0; -set output "output_2.png" +set output "output_$1_bandwidth.png" +plot "bandwidth_stats.$1" using 1:2 smooth bezier with lines lw 2 title 'Upload rate',\ + "bandwidth_stats.$1" using 1:4 smooth bezier with lines lw 2 title 'Download rate',\ + "bandwidth_stats.$1" using 1:6 smooth bezier with lines lw 1 title 'Upload unchoked' axis x1y2,\ + "bandwidth_stats.$1" using 1:7 smooth bezier with lines lw 1 title 'Download unchoked' axis x1y2 -plot "$1" using 1:8 smooth bezier with lines title 'Memory usage' axis x1y1 +set autoscale xfix -set output "output_incore.png" +set output "output_$1_memory.png" +plot "bandwidth_stats.$1" using 1:9 smooth bezier with lines lw 2 title 'Memory usage' axis x1y1,\ + "bandwidth_stats.$1" using 1:6 smooth bezier with lines lw 1 title 'Upload unchoked' axis x1y2,\ + "bandwidth_stats.$1" using 1:7 smooth bezier with lines lw 1 title 'Download unchoked' axis x1y2 + +set format y "%.0f" + +set output "output_$1_incore.png" +plot "bandwidth_stats.$1" using 1:(0) smooth bezier with lines title '',\ + "mincore_stats.$1" using 1:2 smooth bezier with lines lw 1 title 'Incore cont.' axis x1y1,\ + "mincore_stats.$1" using 1:3 smooth bezier with lines lw 2 title 'Incore new' axis x1y2,\ + "mincore_stats.$1" using 1:4 smooth bezier with lines lw 1 title 'Not incore cont.' axis x1y1,\ + "mincore_stats.$1" using 1:5 smooth bezier with lines lw 2 title 'Not incore new' axis x1y2 -plot "$2" using 1:2 smooth bezier with lines title 'Incore cont.' axis x1y1,\ - "$2" using 1:3 smooth bezier with lines title 'Incore new' axis x1y2,\ - "$2" using 1:4 smooth bezier with lines title 'Not incore cont.' axis x1y1,\ - "$2" using 1:5 smooth bezier with lines title 'Not incore new' axis x1y2 EOF diff --git a/src/command_local.cc b/src/command_local.cc index 4462d8b8..1a9d1801 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -65,6 +65,18 @@ typedef torrent::ChunkManager CM_t; typedef torrent::FileManager FM_t; +torrent::Object +apply_pieces_stats_total_size() { + uint64_t size = 0; + core::DownloadList* d_list = control->core()->download_list(); + + for (core::DownloadList::iterator itr = d_list->begin(), last = d_list->end(); itr != last; itr++) + if ((*itr)->is_active()) + size += (*itr)->file_list()->size_bytes(); + + return size; +} + torrent::Object apply_log(const torrent::Object::string_type& arg, int logType) { if (rpc::execFile.log_fd() != -1) { @@ -281,6 +293,7 @@ initialize_command_local() { CMD2_ANY_VALUE_V ("pieces.sync.timeout.set", std::bind(&CM_t::set_timeout_sync, chunkManager, std::placeholders::_2)); CMD2_ANY ("pieces.sync.timeout_safe", std::bind(&CM_t::timeout_safe_sync, chunkManager)); CMD2_ANY_VALUE_V ("pieces.sync.timeout_safe.set", std::bind(&CM_t::set_timeout_safe_sync, chunkManager, std::placeholders::_2)); + CMD2_ANY ("pieces.sync.queue_size", std::bind(&CM_t::sync_queue_size, chunkManager)); CMD2_ANY ("pieces.preload.type", std::bind(&CM_t::preload_type, chunkManager)); CMD2_ANY_VALUE_V ("pieces.preload.type.set", std::bind(&CM_t::set_preload_type, chunkManager, std::placeholders::_2)); @@ -290,11 +303,14 @@ initialize_command_local() { CMD2_ANY_VALUE_V ("pieces.preload.min_rate.set", std::bind(&CM_t::set_preload_required_rate, chunkManager, std::placeholders::_2)); CMD2_ANY ("pieces.memory.current", std::bind(&CM_t::memory_usage, chunkManager)); + CMD2_ANY ("pieces.memory.sync_queue", std::bind(&CM_t::sync_queue_memory_usage, chunkManager)); CMD2_ANY ("pieces.memory.max", std::bind(&CM_t::max_memory_usage, chunkManager)); CMD2_ANY_VALUE_V ("pieces.memory.max.set", std::bind(&CM_t::set_max_memory_usage, chunkManager, std::placeholders::_2)); CMD2_ANY ("pieces.stats_preloaded", std::bind(&CM_t::stats_preloaded, chunkManager)); CMD2_ANY ("pieces.stats_not_preloaded", std::bind(&CM_t::stats_not_preloaded, chunkManager)); + CMD2_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size)); + CMD2_VAR_BOOL ("pieces.hash.on_completion", true); CMD2_VAR_STRING ("directory.default", "./"); @@ -322,7 +338,6 @@ initialize_command_local() { CMD2_ANY_STRING ("log.execute", std::bind(&apply_log, std::placeholders::_2, 0)); CMD2_ANY_STRING ("log.vmmap.dump", std::bind(&log_vmmap_dump, std::placeholders::_2)); CMD2_ANY_STRING_V("log.xmlrpc", std::bind(&ThreadWorker::set_xmlrpc_log, worker_thread, std::placeholders::_2)); - CMD2_ANY_LIST ("log.libtorrent", std::bind(&apply_log_libtorrent, std::placeholders::_2)); // TODO: Convert to new command types: