diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index fa2c56348..0c5e16862 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -179,6 +179,7 @@ namespace libtorrent , cumulative_write_time(0) , cumulative_hash_time(0) , cumulative_sort_time(0) + , total_read_back(0) {} // the number of 16kB blocks written @@ -222,6 +223,7 @@ namespace libtorrent boost::uint32_t cumulative_write_time; boost::uint32_t cumulative_hash_time; boost::uint32_t cumulative_sort_time; + int total_read_back; }; struct TORRENT_EXPORT disk_buffer_pool : boost::noncopyable diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 52200b128..d6834076d 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -348,7 +348,7 @@ namespace libtorrent , int current_slot); void switch_to_full_mode(); - sha1_hash hash_for_piece_impl(int piece); + sha1_hash hash_for_piece_impl(int piece, int* readback = 0); int release_files_impl() { return m_storage->release_files(); } int delete_files_impl() { return m_storage->delete_files(); } diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index a720bfc65..4e341af90 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -2190,7 +2190,8 @@ namespace libtorrent ptime hash_start = time_now_hires(); - sha1_hash h = j.storage->hash_for_piece_impl(j.piece); + int readback = 0; + sha1_hash h = j.storage->hash_for_piece_impl(j.piece, &readback); if (test_error(j)) { ret = -1; @@ -2198,6 +2199,8 @@ namespace libtorrent break; } + m_cache_stats.total_read_back += readback / m_block_size; + ret = (j.storage->info()->hash_for_piece(j.piece) == h)?0:-2; if (ret == -2) j.storage->mark_failed(j.piece); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c611b78b5..69fd3f792 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -964,6 +964,7 @@ namespace aux { ":cumulative write time" ":cumulative hash time" ":cumulative sort time" + ":disk total read back" "\n\n", m_stats_logger); } #endif @@ -2739,7 +2740,7 @@ namespace aux { "%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%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\n" + "%d\t%d\t%d\t%d\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) @@ -2833,6 +2834,7 @@ namespace aux { , int(cs.cumulative_write_time) , int(cs.cumulative_hash_time) , int(cs.cumulative_sort_time) + , cs.total_read_back ); m_last_cache_status = cs; m_last_failed = m_total_failed_bytes; diff --git a/src/storage.cpp b/src/storage.cpp index 7fd5babdf..df8b65032 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -1710,7 +1710,7 @@ ret: return m_save_path; } - sha1_hash piece_manager::hash_for_piece_impl(int piece) + sha1_hash piece_manager::hash_for_piece_impl(int piece, int* readback) { TORRENT_ASSERT(!m_storage->error()); @@ -1725,7 +1725,8 @@ ret: int slot = slot_for(piece); TORRENT_ASSERT(slot != has_no_slot); - hash_for_slot(slot, ph, m_files.piece_size(piece)); + int read = hash_for_slot(slot, ph, m_files.piece_size(piece)); + if (readback) *readback = read; if (m_storage->error()) return sha1_hash(0); return ph.h.final(); }