From 3f94cc8857a981a2ec65dcb48fdc3b8763b0af9b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 14 Jan 2009 09:07:27 +0000 Subject: [PATCH] made the sequential download mode slightly more sequential (by letting more categories of peers request early pieces). Disabled speed affinity and prefer_whole_pieces when in sequential download mode --- include/libtorrent/piece_picker.hpp | 6 +++++- src/peer_connection.cpp | 4 ++-- src/piece_picker.cpp | 10 +++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index cd52ecc4e..c877b8098 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -129,7 +129,11 @@ namespace libtorrent // always pick partial pieces before any other piece prioritize_partials = 8, // pick pieces in sequential order - sequential = 16 + sequential = 16, + // have affinity to pieces with the same speed category + speed_affinity = 32, + // ignore the prefer_whole_pieces parameter + ignore_whole_pieces = 64 }; struct downloading_piece diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 9657b82ed..aa28a473b 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -617,7 +617,7 @@ namespace libtorrent if (t->is_sequential_download()) { - ret |= piece_picker::sequential; + ret |= piece_picker::sequential | piece_picker::ignore_whole_pieces; } else if (t->num_have() < t->settings().initial_picker_threshold) { @@ -628,7 +628,7 @@ namespace libtorrent } else { - ret |= piece_picker::rarest_first; + ret |= piece_picker::rarest_first | piece_picker::speed_affinity; } if (m_snubbed) diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index ea8288f01..370061205 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -1319,6 +1319,12 @@ namespace libtorrent // peer // * prioritize_partials // pick blocks from downloading pieces first + // * speed_affinity + // have an affinity to pick pieces in the same speed + // category. + // * ignore_whole_pieces + // ignores the prefer_whole_pieces parameter (as if + // it was 0) // only one of rarest_first, sequential can be set @@ -1330,6 +1336,8 @@ namespace libtorrent // prevent the number of partial pieces to grow indefinitely if (m_downloads.size() > 20) options |= prioritize_partials; + if (options & ignore_whole_pieces) prefer_whole_pieces = 0; + // only one of rarest_first and sequential can be set. TORRENT_ASSERT(bool(options & rarest_first) + bool(options & sequential) <= 1); @@ -1812,7 +1820,7 @@ namespace libtorrent // if the state of the piece is none (the // piece will in that case change state). if (dp.state != none && dp.state != speed - && !exclusive_active) + && !exclusive_active && (options & speed_affinity)) { if (abs(dp.state - speed) == 1) {