optimize setting with unlimited unchoke slots
This commit is contained in:
parent
97a79d2dba
commit
0c2d3a0dac
|
@ -1,3 +1,4 @@
|
|||
* optimize setting with unlimited unchoke slots
|
||||
* fixed restoring of trackers, comment, creation date and created-by in resume data
|
||||
* fix handling of torrents with too large pieces
|
||||
* fixed division by zero in anti-leech choker
|
||||
|
|
|
@ -1358,7 +1358,8 @@ namespace aux {
|
|||
|
||||
// ``unchoke_slots_limit`` is the max number of unchoked peers in the
|
||||
// session. The number of unchoke slots may be ignored depending on
|
||||
// what ``choking_algorithm`` is set to.
|
||||
// what ``choking_algorithm`` is set to. Setting this limit to -1
|
||||
// means unlimited, i.e. all peers will always be unchoked.
|
||||
unchoke_slots_limit,
|
||||
|
||||
#if TORRENT_ABI_VERSION == 1
|
||||
|
|
|
@ -205,8 +205,8 @@ namespace {
|
|||
// allow lots of peers to try to connect simultaneously
|
||||
set.set_int(settings_pack::listen_queue_size, 3000);
|
||||
|
||||
// unchoke many peers
|
||||
set.set_int(settings_pack::unchoke_slots_limit, 2000);
|
||||
// unchoke all peers
|
||||
set.set_int(settings_pack::unchoke_slots_limit, -1);
|
||||
|
||||
// use 1 GB of cache
|
||||
set.set_int(settings_pack::cache_size, 32768 * 2);
|
||||
|
|
|
@ -3909,6 +3909,9 @@ namespace aux {
|
|||
TORRENT_ASSERT(is_single_thread());
|
||||
if (m_stats_counters[counters::num_unchoke_slots] == 0) return;
|
||||
|
||||
// if we unchoke everyone, skip this logic
|
||||
if (settings().get_int(settings_pack::unchoke_slots_limit) < 0) return;
|
||||
|
||||
std::vector<opt_unchoke_candidate> opt_unchoke;
|
||||
|
||||
// collect the currently optimistically unchoked peers here, so we can
|
||||
|
@ -4174,6 +4177,13 @@ namespace aux {
|
|||
time_duration const unchoke_interval = now - m_last_choke;
|
||||
m_last_choke = now;
|
||||
|
||||
// if we unchoke everyone, skip this logic
|
||||
if (settings().get_int(settings_pack::unchoke_slots_limit) < 0)
|
||||
{
|
||||
m_stats_counters.set_value(counters::num_unchoke_slots, std::numeric_limits<int>::max());
|
||||
return;
|
||||
}
|
||||
|
||||
// build list of all peers that are
|
||||
// unchokable.
|
||||
// TODO: 3 there should be a pre-calculated list of all peers eligible for
|
||||
|
@ -6298,6 +6308,25 @@ namespace aux {
|
|||
m_alerts.emplace_alert<performance_alert>(torrent_handle()
|
||||
, performance_alert::too_many_optimistic_unchoke_slots);
|
||||
}
|
||||
|
||||
if (allowed_upload_slots == std::numeric_limits<int>::max())
|
||||
{
|
||||
// this means we're not aplpying upload slot limits, unchoke
|
||||
// everyone
|
||||
for (auto const& p : m_connections)
|
||||
{
|
||||
if (p->is_disconnecting() || p->is_connecting())
|
||||
continue;
|
||||
|
||||
auto const t = p->associated_torrent().lock();
|
||||
t->unchoke_peer(*p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// trigger recalculating unchoke slots
|
||||
m_unchoke_time_scaler = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void session_impl::update_connection_speed()
|
||||
|
|
Loading…
Reference in New Issue