From 4e9d240585ad5e19f1e145e8334b36b32dbd7620 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 2 Nov 2024 12:08:10 +0100 Subject: [PATCH] measure disk cache size in performance counters --- include/libtorrent/performance_counters.hpp | 1 + src/pread_disk_io.cpp | 1 + src/session_stats.cpp | 1 + tools/parse_session_stats.py | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index e7f63ae2929..44ca6042443 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -378,6 +378,7 @@ namespace libtorrent { request_latency, disk_blocks_in_use, + disk_cache_pieces, queued_disk_jobs, num_running_disk_jobs, num_read_jobs, diff --git a/src/pread_disk_io.cpp b/src/pread_disk_io.cpp index 449646c7aee..da7cb49f1ae 100644 --- a/src/pread_disk_io.cpp +++ b/src/pread_disk_io.cpp @@ -1145,6 +1145,7 @@ void pread_disk_io::update_stats_counters(counters& c) const // gauges c.set_value(counters::disk_blocks_in_use, m_buffer_pool.in_use()); + c.set_value(counters::disk_cache_pieces, m_cache.size()); } status_t pread_disk_io::do_job(aux::job::file_priority& a, aux::pread_disk_job* j) diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 49f0d1f91f0..b2e75da6148 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -306,6 +306,7 @@ namespace { METRIC(disk, request_latency) METRIC(disk, disk_blocks_in_use) + METRIC(disk, disk_cache_pieces) // ``queued_disk_jobs`` is the number of disk jobs currently queued, // waiting to be executed by a disk thread. diff --git a/tools/parse_session_stats.py b/tools/parse_session_stats.py index bf27d4133c3..368388dde05 100755 --- a/tools/parse_session_stats.py +++ b/tools/parse_session_stats.py @@ -623,6 +623,10 @@ def gen_html(reports, generations): ('queued_trackers', 'number of queued tracker announces', '', '', [ \ 'tracker.num_queued_tracker_announces' \ ]), + ('disk_cache', 'disk cache size', '', '', [ \ + 'disk.disk_cache_pieces', \ + 'disk.disk_blocks_in_use', \ + ]), # ('picker_full_partials_distribution', 'full pieces', '', '', ['num full partial pieces'], # {'type': histogram, 'binwidth': 5, 'numbins': 120}),