diff --git a/docs/gen_stats_doc.py b/docs/gen_stats_doc.py index cd11b7593..39f8611a7 100644 --- a/docs/gen_stats_doc.py +++ b/docs/gen_stats_doc.py @@ -1,3 +1,36 @@ +counter_types = {} + +f = open('../include/libtorrent/performance_counters.hpp') + +counter_type = '' + +for l in f: + l = l.strip() + + if l.startswith('//'): continue + if l.startswith('#'): continue + if l == '': continue + + if 'enum stats_counter_t' in l: + counter_type = 'counter' + continue + + if 'enum stats_gauges_t' in l: + counter_type = 'gauge' + continue + + if '{' in l or '}' in l or 'struct' in l or 'namespace' in l: continue + if counter_type == '': continue + if not l.endswith(','): continue + + # strip off trailing comma + l = l[:-1] + if '=' in l: l = l[:l.index('=')].strip() + + counter_types[l] = counter_type + +f.close() + f = open('../src/session_stats.cpp') out = open('stats_counters.rst', 'w+') @@ -61,14 +94,12 @@ for l in f: # args: category, name, type + args[1] = args[1].strip() names.append(args[0].strip() + '.' + args[1].strip()) - - # strip type_ prefix of type_gauge and type_counter - args[2] = args[2].strip()[5:] - types.append(args[2]) + types.append(counter_types[args[1]]) if len(names) > 0: - render_section(names, decsription, types) + render_section(names, description, types) out.close() f.close() diff --git a/docs/gen_todo.py b/docs/gen_todo.py index 43a87c18d..fb457418a 100644 --- a/docs/gen_todo.py +++ b/docs/gen_todo.py @@ -3,12 +3,12 @@ import os paths = ['src/*.cpp', 'src/kademlia/*.cpp', 'include/libtorrent/*.hpp', 'include/libtorrent/kademlia/*.hpp', 'include/libtorrent/aux_/*.hpp', 'include/libtorrent/extensions/*.hpp'] -os.system('ctags %s 2>/dev/null' % ' '.join(paths)) +os.system('(cd .. ; ctags %s 2>/dev/null)' % ' '.join(paths)) files = [] for p in paths: - files.extend(glob.glob(p)) + files.extend(glob.glob(os.path.join('..', p))) items = [] diff --git a/docs/makefile b/docs/makefile index c9da992f8..4bc360d9b 100644 --- a/docs/makefile +++ b/docs/makefile @@ -55,7 +55,7 @@ all: html settings.rst: ../include/libtorrent/settings_pack.hpp python gen_settings_doc.py -stats_counters.rst: ../src/session_stats.cpp +stats_counters.rst: ../src/session_stats.cpp ../include/libtorrent/performance_counters.hpp python gen_stats_doc.py manual.rst: stats_counters.rst diff --git a/docs/stats_counters.rst b/docs/stats_counters.rst index 6597178ec..01810be66 100644 --- a/docs/stats_counters.rst +++ b/docs/stats_counters.rst @@ -16,6 +16,9 @@ +-------------------------+---------+ +TODO: 3 the type of counter does not need to be stored in this array. +when the user asks for the list of counters, that field could be +generated based on the range of the counter index. ``error_peers`` is the total number of peer disconnects caused by an error (not initiated by this client) and disconnected initiated by this client (``disconnected_peers``). @@ -950,24 +953,6 @@ the number of pieces considered while picking pieces .. _disk.read_cache_blocks: -.. _disk.pinned_blocks: - -.. _disk.disk_blocks_in_use: - -.. _disk.queued_disk_jobs: - -.. _disk.num_read_jobs: - -.. _disk.num_write_jobs: - -.. _disk.num_jobs: - -.. _disk.num_writing_threads: - -.. _disk.num_running_threads: - -.. _disk.blocked_disk_jobs: - .. raw:: html @@ -980,15 +965,6 @@ the number of pieces considered while picking pieces - - - - - - - - - +---------------------------------------+---------+ | name | type | @@ -1013,29 +989,72 @@ the number of pieces considered while picking pieces +---------------------------------------+---------+ | disk.read_cache_blocks | gauge | +---------------------------------------+---------+ -| disk.pinned_blocks | gauge | -+---------------------------------------+---------+ -| disk.disk_blocks_in_use | gauge | -+---------------------------------------+---------+ -| disk.queued_disk_jobs | gauge | -+---------------------------------------+---------+ -| disk.num_read_jobs | gauge | -+---------------------------------------+---------+ -| disk.num_write_jobs | gauge | -+---------------------------------------+---------+ -| disk.num_jobs | gauge | -+---------------------------------------+---------+ -| disk.num_writing_threads | gauge | -+---------------------------------------+---------+ -| disk.num_running_threads | gauge | -+---------------------------------------+---------+ -| disk.blocked_disk_jobs | gauge | -+---------------------------------------+---------+ This breaks down the piece picks into the event that triggered it +.. _disk.request_latency: + +.. _disk.pinned_blocks: + +.. _disk.disk_blocks_in_use: + +.. _disk.queued_disk_jobs: + +.. _disk.num_read_jobs: + +.. _disk.num_write_jobs: + +.. _disk.num_jobs: + +.. _disk.num_writing_threads: + +.. _disk.num_running_threads: + +.. _disk.blocked_disk_jobs: + +.. raw:: html + + + + + + + + + + + + ++--------------------------+-------+ +| name | type | ++==========================+=======+ +| disk.request_latency | gauge | ++--------------------------+-------+ +| disk.pinned_blocks | gauge | ++--------------------------+-------+ +| disk.disk_blocks_in_use | gauge | ++--------------------------+-------+ +| disk.queued_disk_jobs | gauge | ++--------------------------+-------+ +| disk.num_read_jobs | gauge | ++--------------------------+-------+ +| disk.num_write_jobs | gauge | ++--------------------------+-------+ +| disk.num_jobs | gauge | ++--------------------------+-------+ +| disk.num_writing_threads | gauge | ++--------------------------+-------+ +| disk.num_running_threads | gauge | ++--------------------------+-------+ +| disk.blocked_disk_jobs | gauge | ++--------------------------+-------+ + + +the number of microseconds it takes from receiving a request from a +peer until we're sending the response back on the socket. + .. _disk.queued_write_bytes: .. _disk.arc_mru_size: @@ -1142,6 +1161,47 @@ bytes just hanging out in the cache) cumulative time spent in various disk jobs, as well as total for all disk jobs. Measured in microseconds +.. _ses.waste_piece_timed_out: + +.. _ses.waste_piece_cancelled: + +.. _ses.waste_piece_unknown: + +.. _ses.waste_piece_seed: + +.. _ses.waste_piece_end_game: + +.. _ses.waste_piece_closing: + +.. raw:: html + + + + + + + + ++---------------------------+---------+ +| name | type | ++===========================+=========+ +| ses.waste_piece_timed_out | counter | ++---------------------------+---------+ +| ses.waste_piece_cancelled | counter | ++---------------------------+---------+ +| ses.waste_piece_unknown | counter | ++---------------------------+---------+ +| ses.waste_piece_seed | counter | ++---------------------------+---------+ +| ses.waste_piece_end_game | counter | ++---------------------------+---------+ +| ses.waste_piece_closing | counter | ++---------------------------+---------+ + + +the number of wasted downloaded bytes by reason of the bytes being +wasted. + .. _dht.dht_nodes: .. raw:: html @@ -1442,7 +1502,8 @@ by kind. +------------------------------+---------+ -uTP counters +uTP counters. Each counter represents the number of time each event +has occurred. .. _sock_bufs.socket_send_size3: diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 7eab8fe6a..aeed86efb 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -302,7 +302,8 @@ namespace libtorrent { num_checking_torrents = num_stats_counters, num_stopped_torrents, - num_upload_only_torrents, // i.e. finished + // upload_only means finished + num_upload_only_torrents, num_downloading_torrents, num_seeding_torrents, num_queued_seeding_torrents, diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 4340ddec3..6f160276d 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -2780,6 +2780,9 @@ namespace libtorrent { // These are atomic_counts, so it's safe to access them from // a different thread + + // TODO: 3 instead of updating these counters in this function, + // they could be updated every time a job completes c.set_value(counters::disk_read_time, m_cache_stats.cumulative_read_time); c.set_value(counters::disk_write_time, m_cache_stats.cumulative_write_time); c.set_value(counters::disk_hash_time, m_cache_stats.cumulative_hash_time); diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 43eda153e..8f257a9ab 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -386,7 +386,8 @@ namespace libtorrent METRIC(dht, dht_put_in) METRIC(dht, dht_put_out) - // uTP counters + // uTP counters. Each counter represents the number of time each event + // has occurred. METRIC(utp, utp_packet_loss) METRIC(utp, utp_timeout) METRIC(utp, utp_packets_in)