removed sparse-regions support
This commit is contained in:
parent
d887f5719d
commit
d1670c72c2
|
@ -1,3 +1,4 @@
|
|||
* removed sparse-regions feature
|
||||
* support using 0 disk threads (to perform disk I/O in network thread)
|
||||
* removed deprecated handle_alert template
|
||||
* enable logging build config by default (but alert mask disabled by default)
|
||||
|
|
|
@ -91,7 +91,6 @@ void bind_torrent_status()
|
|||
.def_readonly("seed_rank", &torrent_status::seed_rank)
|
||||
.def_readonly("last_scrape", &torrent_status::last_scrape)
|
||||
.def_readonly("has_incoming", &torrent_status::has_incoming)
|
||||
.def_readonly("sparse_regions", &torrent_status::sparse_regions)
|
||||
.def_readonly("seed_mode", &torrent_status::seed_mode)
|
||||
.def_readonly("upload_mode", &torrent_status::upload_mode)
|
||||
.def_readonly("share_mode", &torrent_status::share_mode)
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace libtorrent
|
|||
// hash check for this piece
|
||||
boost::uint16_t outstanding_hash_check:1;
|
||||
};
|
||||
|
||||
|
||||
piece_picker();
|
||||
|
||||
void get_availability(std::vector<int>& avail) const;
|
||||
|
@ -225,7 +225,7 @@ namespace libtorrent
|
|||
// decreases the peer count for the given piece
|
||||
// (used when a peer disconnects)
|
||||
void dec_refcount(bitfield const& bitmask, const void* peer);
|
||||
|
||||
|
||||
// these will increase and decrease the peer count
|
||||
// of all pieces. They are used when seeds join
|
||||
// or leave the swarm.
|
||||
|
@ -241,12 +241,10 @@ namespace libtorrent
|
|||
|
||||
// the lowest piece index we do not have
|
||||
int cursor() const { return m_cursor; }
|
||||
|
||||
|
||||
// one past the last piece we do not have.
|
||||
int reverse_cursor() const { return m_reverse_cursor; }
|
||||
|
||||
int sparse_regions() const { return m_sparse_regions; }
|
||||
|
||||
// sets all pieces to dont-have
|
||||
void init(int blocks_per_piece, int blocks_in_last_piece, int total_num_pieces);
|
||||
int num_pieces() const { return int(m_piece_map.size()); }
|
||||
|
@ -811,7 +809,7 @@ namespace libtorrent
|
|||
|
||||
// the number of pieces we have that also are filtered
|
||||
int m_num_have_filtered;
|
||||
|
||||
|
||||
// we have all pieces in the range [0, m_cursor)
|
||||
// m_cursor is the first piece we don't have
|
||||
int m_cursor;
|
||||
|
@ -821,13 +819,10 @@ namespace libtorrent
|
|||
// all the subsequent pieces
|
||||
int m_reverse_cursor;
|
||||
|
||||
// the number of regions of pieces we don't have.
|
||||
int m_sparse_regions;
|
||||
|
||||
// the number of pieces we have (i.e. passed + flushed).
|
||||
// This includes pieces that we have filtered but still have
|
||||
int m_num_have;
|
||||
|
||||
|
||||
// this is the number of partial download pieces
|
||||
// that may be caused by pad files. We raise the limit
|
||||
// of number of partial pieces by this amount, to not
|
||||
|
|
|
@ -1083,17 +1083,6 @@ namespace libtorrent
|
|||
// favour of a choked peer.
|
||||
seeding_piece_quota,
|
||||
|
||||
// ``max_sparse_regions`` is a limit of the number of *sparse regions*
|
||||
// in a torrent. A sparse region is defined as a hole of pieces we
|
||||
// have not yet downloaded, in between pieces that have been
|
||||
// downloaded. This is used as a hack for windows vista which has a
|
||||
// bug where you cannot write files with more than a certain number of
|
||||
// sparse regions. This limit is not hard, it will be exceeded. Once
|
||||
// it's exceeded, pieces that will maintain or decrease the number of
|
||||
// sparse regions are prioritized. To disable this functionality, set
|
||||
// this to 0. It defaults to 0 on all platforms except windows.
|
||||
max_sparse_regions,
|
||||
|
||||
// TODO: deprecate this
|
||||
// ``max_rejects`` is the number of piece requests we will reject in a
|
||||
// row while a peer is choked before the peer is considered abusive
|
||||
|
|
|
@ -1145,8 +1145,6 @@ namespace libtorrent
|
|||
|
||||
private:
|
||||
|
||||
void update_sparse_piece_prio(int piece, int start, int end);
|
||||
|
||||
void ip_filter_updated();
|
||||
|
||||
void inc_stats_counter(int c, int value = 1);
|
||||
|
@ -1537,11 +1535,6 @@ namespace libtorrent
|
|||
// does not count when the torrent is stopped or paused
|
||||
unsigned int m_seeding_time:24;
|
||||
|
||||
// this is a counter that is decreased every
|
||||
// second, and when it reaches 0, the peer_list::pulse()
|
||||
// is called and the time scaler is reset to 10.
|
||||
boost::int8_t m_time_scaler;
|
||||
|
||||
// ----
|
||||
|
||||
// the maximum number of uploads for this torrent
|
||||
|
|
|
@ -1581,11 +1581,6 @@ namespace libtorrent
|
|||
// If it has never done that, this value is -1.
|
||||
int last_scrape;
|
||||
|
||||
// the number of regions of non-downloaded pieces in the torrent. This is
|
||||
// an interesting metric on windows vista, since there is a limit on the
|
||||
// number of sparse regions in a single file there.
|
||||
int sparse_regions;
|
||||
|
||||
// the priority of this torrent
|
||||
int priority;
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ namespace libtorrent
|
|||
, m_num_have_filtered(0)
|
||||
, m_cursor(0)
|
||||
, m_reverse_cursor(0)
|
||||
, m_sparse_regions(1)
|
||||
, m_num_have(0)
|
||||
, m_num_pad_files(0)
|
||||
, m_dirty(false)
|
||||
|
@ -137,7 +136,7 @@ namespace libtorrent
|
|||
// the piece index is stored in 20 bits, which limits the allowed
|
||||
// number of pieces somewhat
|
||||
TORRENT_ASSERT(m_piece_map.size() < piece_pos::we_have_index);
|
||||
|
||||
|
||||
m_blocks_per_piece = blocks_per_piece;
|
||||
m_blocks_in_last_piece = blocks_in_last_piece;
|
||||
if (m_blocks_in_last_piece == 0) m_blocks_in_last_piece = blocks_per_piece;
|
||||
|
@ -150,7 +149,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
#endif
|
||||
|
||||
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < int(m_piece_map.size()));
|
||||
|
||||
|
@ -271,7 +270,7 @@ namespace libtorrent
|
|||
// since we're removing a downloading_piece, we also need to free its
|
||||
// blocks that are allocated from the m_block_info array.
|
||||
m_free_block_infos.push_back(i->info_idx);
|
||||
|
||||
|
||||
TORRENT_ASSERT(find_dl_piece(download_state, i->index) == i);
|
||||
m_piece_map[i->index].download_state = piece_pos::piece_open;
|
||||
m_downloads[download_state].erase(i);
|
||||
|
@ -375,7 +374,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(!m_piece_map[i->piece_index].filtered());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void piece_picker::verify_priority(int range_start, int range_end, int prio) const
|
||||
{
|
||||
TORRENT_ASSERT(range_start <= range_end);
|
||||
|
@ -961,7 +960,7 @@ namespace libtorrent
|
|||
int index = m_pieces[elem_index];
|
||||
// update the piece_map
|
||||
piece_pos& p = m_piece_map[index];
|
||||
TORRENT_ASSERT(int(p.index) == elem_index || p.have());
|
||||
TORRENT_ASSERT(int(p.index) == elem_index || p.have());
|
||||
|
||||
int new_priority = p.priority(this);
|
||||
|
||||
|
@ -1071,7 +1070,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(elem_index >= 0);
|
||||
TORRENT_ASSERT(elem_index < int(m_pieces.size()));
|
||||
TORRENT_ASSERT(m_piece_map[m_pieces[elem_index]].priority(this) == priority);
|
||||
|
||||
|
||||
int range_start, range_end;
|
||||
priority_range(priority, &range_start, &range_end);
|
||||
TORRENT_ASSERT(range_start < range_end);
|
||||
|
@ -1217,7 +1216,7 @@ namespace libtorrent
|
|||
std::cerr << "[" << this << "] " << "inc_refcount(" << index << ")" << std::endl;
|
||||
#endif
|
||||
piece_pos& p = m_piece_map[index];
|
||||
|
||||
|
||||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(p.have_peers.count(peer) == 0);
|
||||
p.have_peers.insert(peer);
|
||||
|
@ -1599,7 +1598,7 @@ namespace libtorrent
|
|||
++m_num_passed;
|
||||
|
||||
if (i->finished < blocks_in_piece(index)) return;
|
||||
|
||||
|
||||
we_have(index);
|
||||
}
|
||||
|
||||
|
@ -1698,27 +1697,6 @@ namespace libtorrent
|
|||
erase_download_piece(i);
|
||||
}
|
||||
|
||||
// maintain sparse_regions
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == int(m_piece_map.size()) - 1
|
||||
|| m_piece_map[index + 1].have())
|
||||
--m_sparse_regions;
|
||||
}
|
||||
else if (index == int(m_piece_map.size() - 1))
|
||||
{
|
||||
if (index == 0
|
||||
|| m_piece_map[index - 1].have())
|
||||
--m_sparse_regions;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool have_before = m_piece_map[index-1].have();
|
||||
bool have_after = m_piece_map[index+1].have();
|
||||
if (have_after && have_before) --m_sparse_regions;
|
||||
else if (!have_after && !have_before) ++m_sparse_regions;
|
||||
}
|
||||
|
||||
if (p.filtered())
|
||||
{
|
||||
--m_num_filtered;
|
||||
|
@ -1775,12 +1753,12 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(new_piece_priority < priority_levels);
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < (int)m_piece_map.size());
|
||||
|
||||
|
||||
piece_pos& p = m_piece_map[index];
|
||||
|
||||
// if the priority isn't changed, don't do anything
|
||||
if (new_piece_priority == int(p.piece_priority)) return false;
|
||||
|
||||
|
||||
int prev_priority = p.priority(this);
|
||||
TORRENT_ASSERT(m_dirty || prev_priority < int(m_priority_boundries.size()));
|
||||
|
||||
|
@ -1848,7 +1826,7 @@ namespace libtorrent
|
|||
}
|
||||
TORRENT_ASSERT(m_num_filtered >= 0);
|
||||
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
||||
|
||||
|
||||
p.piece_priority = new_piece_priority;
|
||||
int new_priority = p.priority(this);
|
||||
|
||||
|
@ -2023,7 +2001,7 @@ namespace libtorrent
|
|||
std::vector<piece_block> backup_blocks;
|
||||
std::vector<piece_block> backup_blocks2;
|
||||
const std::vector<int> empty_vector;
|
||||
|
||||
|
||||
// When prefer_contiguous_blocks is set (usually set when downloading from
|
||||
// fast peers) the partial pieces will not be prioritized, but actually
|
||||
// ignored as long as possible. All blocks found in downloading
|
||||
|
@ -2141,7 +2119,7 @@ namespace libtorrent
|
|||
if (options & reverse)
|
||||
{
|
||||
for (int i = m_reverse_cursor - 1; i >= m_cursor; --i)
|
||||
{
|
||||
{
|
||||
pc.inc_stats_counter(counters::piece_picker_sequential_loops);
|
||||
if (!is_piece_free(i, pieces)) continue;
|
||||
// we've already added high priority pieces
|
||||
|
@ -2648,7 +2626,6 @@ get_out:
|
|||
return boost::make_tuple(exclusive, exclusive_active, max_contiguous
|
||||
, first_block);
|
||||
}
|
||||
|
||||
|
||||
int piece_picker::add_blocks(int piece
|
||||
, bitfield const& pieces
|
||||
|
@ -2814,7 +2791,7 @@ get_out:
|
|||
}
|
||||
if (num_blocks <= 0) return 0;
|
||||
}
|
||||
|
||||
|
||||
TORRENT_ASSERT(num_blocks >= 0 || prefer_contiguous_blocks > 0);
|
||||
|
||||
if (num_blocks <= 0) return 0;
|
||||
|
@ -2827,7 +2804,7 @@ get_out:
|
|||
#endif
|
||||
return num_blocks;
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, int> piece_picker::expand_piece(int piece, int contiguous_blocks
|
||||
, bitfield const& have, int options) const
|
||||
{
|
||||
|
@ -3250,7 +3227,7 @@ get_out:
|
|||
{
|
||||
TORRENT_ASSERT(m_seeds >= 0);
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
|
||||
|
||||
avail.resize(m_piece_map.size());
|
||||
std::vector<int>::iterator j = avail.begin();
|
||||
for (std::vector<piece_pos>::const_iterator i = m_piece_map.begin()
|
||||
|
@ -3476,7 +3453,7 @@ get_out:
|
|||
piece_pos& p = m_piece_map[block.piece_index];
|
||||
|
||||
if (p.download_queue() == piece_pos::piece_open) return;
|
||||
|
||||
|
||||
std::vector<downloading_piece>::iterator i = find_dl_piece(p.download_queue()
|
||||
, block.piece_index);
|
||||
|
||||
|
@ -3548,7 +3525,7 @@ get_out:
|
|||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
#endif
|
||||
|
||||
|
||||
int prio = p.priority(this);
|
||||
TORRENT_ASSERT(prio < int(m_priority_boundries.size())
|
||||
|| m_dirty);
|
||||
|
@ -3574,7 +3551,7 @@ get_out:
|
|||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
#endif
|
||||
|
||||
|
||||
std::vector<downloading_piece>::iterator i = find_dl_piece(p.download_queue()
|
||||
, block.piece_index);
|
||||
TORRENT_ASSERT(i != m_downloads[p.download_queue()].end());
|
||||
|
@ -3607,7 +3584,7 @@ get_out:
|
|||
}
|
||||
|
||||
i = update_piece_state(i);
|
||||
|
||||
|
||||
if (i->finished < blocks_in_piece(i->index))
|
||||
return;
|
||||
|
||||
|
|
|
@ -275,11 +275,6 @@ namespace libtorrent
|
|||
SET(min_announce_interval, 5 * 60, 0),
|
||||
SET(auto_manage_startup, 60, 0),
|
||||
SET(seeding_piece_quota, 20, 0),
|
||||
#ifdef TORRENT_WINDOWS
|
||||
SET(max_sparse_regions, 30000, 0),
|
||||
#else
|
||||
SET(max_sparse_regions, 0, 0),
|
||||
#endif
|
||||
SET(max_rejects, 50, 0),
|
||||
SET(recv_socket_buffer_size, 0, &session_impl::update_socket_buffer_size),
|
||||
SET(send_socket_buffer_size, 0, &session_impl::update_socket_buffer_size),
|
||||
|
|
|
@ -238,7 +238,6 @@ namespace libtorrent
|
|||
#endif
|
||||
, m_need_save_resume_data(true)
|
||||
, m_seeding_time(0)
|
||||
, m_time_scaler(0)
|
||||
, m_max_uploads((1<<24)-1)
|
||||
, m_save_resume_flags(0)
|
||||
, m_num_uploads(0)
|
||||
|
@ -2655,7 +2654,7 @@ namespace libtorrent
|
|||
debug_log("start_checking, m_checking_piece: %d", m_checking_piece);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// This is only used for checking of torrents. i.e. force-recheck or initial checking
|
||||
// of existing files
|
||||
void torrent::on_piece_hashed(disk_io_job const* j)
|
||||
|
@ -3292,7 +3291,7 @@ namespace libtorrent
|
|||
// these numbers are cached in the resume data
|
||||
m_need_save_resume_data = true;
|
||||
}
|
||||
|
||||
|
||||
void torrent::tracker_response(
|
||||
tracker_request const& r
|
||||
, address const& tracker_ip // this is the IP we connected to
|
||||
|
@ -4077,20 +4076,6 @@ namespace libtorrent
|
|||
|
||||
}
|
||||
|
||||
void torrent::update_sparse_piece_prio(int i, int start, int end)
|
||||
{
|
||||
TORRENT_ASSERT(m_picker);
|
||||
if (m_picker->have_piece(i) || m_picker->piece_priority(i) == 0)
|
||||
return;
|
||||
bool have_before = i < start || m_picker->have_piece(i - 1);
|
||||
bool have_after = i >= end || m_picker->have_piece(i + 1);
|
||||
if (have_after && have_before)
|
||||
m_picker->set_piece_priority(i, 7);
|
||||
else if (have_after || have_before)
|
||||
m_picker->set_piece_priority(i, 6);
|
||||
update_gauge();
|
||||
}
|
||||
|
||||
// this is called once we have completely downloaded piece
|
||||
// 'index', its hash has been verified. It's also called
|
||||
// during initial file check when we find a piece whose hash
|
||||
|
@ -4139,20 +4124,6 @@ namespace libtorrent
|
|||
else p->fill_send_buffer();
|
||||
}
|
||||
|
||||
if (settings().get_int(settings_pack::max_sparse_regions) > 0
|
||||
&& has_picker()
|
||||
&& m_picker->sparse_regions() > settings().get_int(settings_pack::max_sparse_regions))
|
||||
{
|
||||
// we have too many sparse regions. Prioritize pieces
|
||||
// that won't introduce new sparse regions
|
||||
// prioritize pieces that will reduce the number of sparse
|
||||
// regions even higher
|
||||
int start = m_picker->cursor();
|
||||
int end = m_picker->reverse_cursor();
|
||||
if (index > start) update_sparse_piece_prio(index - 1, start, end);
|
||||
if (index < end - 1) update_sparse_piece_prio(index + 1, start, end);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
|
@ -9817,26 +9788,6 @@ namespace libtorrent
|
|||
if (m_need_suggest_pieces_refresh)
|
||||
do_refresh_suggest_pieces();
|
||||
|
||||
m_time_scaler--;
|
||||
if (m_time_scaler <= 0)
|
||||
{
|
||||
m_time_scaler = 10;
|
||||
|
||||
if (settings().get_int(settings_pack::max_sparse_regions) > 0
|
||||
&& has_picker()
|
||||
&& m_picker->sparse_regions() > settings().get_int(settings_pack::max_sparse_regions))
|
||||
{
|
||||
// we have too many sparse regions. Prioritize pieces
|
||||
// that won't introduce new sparse regions
|
||||
// prioritize pieces that will reduce the number of sparse
|
||||
// regions even higher
|
||||
int start = m_picker->cursor();
|
||||
int end = m_picker->reverse_cursor();
|
||||
for (int i = start; i < end; ++i)
|
||||
update_sparse_piece_prio(i, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings().get_bool(settings_pack::rate_limit_ip_overhead))
|
||||
{
|
||||
int up_limit = upload_limit();
|
||||
|
@ -11636,7 +11587,6 @@ namespace libtorrent
|
|||
int num_pieces = m_torrent_file->num_pieces();
|
||||
if (has_picker() && (flags & torrent_handle::query_pieces))
|
||||
{
|
||||
st->sparse_regions = m_picker->sparse_regions();
|
||||
st->pieces.resize(num_pieces, false);
|
||||
for (int i = 0; i < num_pieces; ++i)
|
||||
if (m_picker->has_piece_passed(i)) st->pieces.set_bit(i);
|
||||
|
|
|
@ -119,7 +119,6 @@ namespace libtorrent
|
|||
, seeding_time(0)
|
||||
, seed_rank(0)
|
||||
, last_scrape(0)
|
||||
, sparse_regions(0)
|
||||
, priority(0)
|
||||
, state(checking_resume_data)
|
||||
, need_save_resume(false)
|
||||
|
|
Loading…
Reference in New Issue