add send_watermark_factor

This commit is contained in:
Arvid Norberg 2010-03-12 02:36:55 +00:00
parent 8efc16c3bd
commit 06a043a489
4 changed files with 26 additions and 2 deletions

View File

@ -3710,6 +3710,7 @@ session_settings
bool free_torrent_hashes;
bool upnp_ignore_nonrouters;
int send_buffer_watermark;
int send_buffer_watermark_factor;
#ifndef TORRENT_NO_DEPRECATE
bool auto_upload_slots;
@ -4008,12 +4009,18 @@ should ignore any broadcast response from a device whose address is not the
configured router for this machine. i.e. it's a way to not talk to other
people's routers by mistake.
``send_buffer_waterbark`` is the upper limit of the send buffer low-watermark.
``send_buffer_watermark`` is the upper limit of the send buffer low-watermark.
if the send buffer has fewer bytes than this, we'll read another 16kB block
onto it. If set too small, upload rate capacity will suffer. If set too high,
memory will be wasted. The actual watermark may be lower than this in case
the upload rate is low, this is the upper limit.
``send_buffer_watermark_factor`` is multiplied to the peer's upload rate
to determine the low-watermark for the peer. This is clamped to not
exceed the ``send_buffer_watermark`` upper limit. This defaults to 1.
For high capacity connections, setting this higher can improve upload
performance and disk throughput.
``auto_upload_slots`` defaults to true. When true, if there is a global upload
limit set and the current upload rate is less than 90% of that, another upload
slot is opened. If the upload rate has been saturated for an extended period

View File

@ -123,6 +123,7 @@ namespace libtorrent
, free_torrent_hashes(true)
, upnp_ignore_nonrouters(false)
, send_buffer_watermark(100 * 1024)
, send_buffer_watermark_factor(1)
#ifndef TORRENT_NO_DEPRECATE
// deprecated in 0.16
, auto_upload_slots(true)
@ -410,6 +411,14 @@ namespace libtorrent
// the upload rate is low, this is the upper limit.
int send_buffer_watermark;
// the current upload rate to a peer is multiplied by
// this factor to get the send buffer watermark. This
// product is clamped to the send_buffer_watermark
// setting to not exceed the max. For high speed
// upload, this should be set to a greater value than
// 1. The default is 1.
int send_buffer_watermark_factor;
#ifndef TORRENT_NO_DEPRECATE
// deprecated in 0.16
bool auto_upload_slots;

View File

@ -3988,11 +3988,14 @@ namespace libtorrent
// only add new piece-chunks if the send buffer is small enough
// otherwise there will be no end to how large it will be!
int buffer_size_watermark = int(m_statistics.upload_rate()) / 2;
int buffer_size_watermark = int(m_statistics.upload_rate())
* m_ses.settings().send_buffer_watermark_factor;
if (buffer_size_watermark < 512) buffer_size_watermark = 512;
else if (buffer_size_watermark > m_ses.settings().send_buffer_watermark)
{
buffer_size_watermark = m_ses.settings().send_buffer_watermark;
// #error only trigger this if we actually run out of send buffer
// while we're waiting for the disk
if (t->alerts().should_post<performance_alert>())
{
t->alerts().post_alert(performance_alert(t->get_handle()

View File

@ -213,6 +213,11 @@ namespace libtorrent
// limit should be 5 MB
set.send_buffer_watermark = 5 * 1024 * 1024;
// put 10 seconds worth of data in the send buffer
// this gives the disk I/O more heads-up on disk
// reads, and can maximize throughput
set.send_buffer_watermark_factor = 10;
// don't retry peers if they fail once. Let them
// connect to us if they want to
set.max_failcount = 1;