diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index 5eea82cce..6c66f6e6e 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -49,6 +49,7 @@ void bind_session_settings() #endif .def_readwrite("free_torrent_hashes", &session_settings::free_torrent_hashes) .def_readwrite("upnp_ignore_nonrouters", &session_settings::upnp_ignore_nonrouters) + .def_readwrite("send_buffer_low_watermark", &session_settings::send_buffer_low_watermark) .def_readwrite("send_buffer_watermark", &session_settings::send_buffer_watermark) #ifndef TORRENT_NO_DEPRECATE .def_readwrite("auto_upload_slots", &session_settings::auto_upload_slots) diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 4378c9479..b584e95a4 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -136,6 +136,7 @@ namespace libtorrent #endif , free_torrent_hashes(true) , upnp_ignore_nonrouters(false) + , send_buffer_low_watermark(512) , send_buffer_watermark(500 * 1024) , send_buffer_watermark_factor(50) #ifndef TORRENT_NO_DEPRECATE @@ -476,6 +477,14 @@ namespace libtorrent // our currently configured router. bool upnp_ignore_nonrouters; + // This is the minimum send buffer target size (send buffer + // includes bytes pending being read from disk). For good + // and snappy seeding performance, set this fairly high, to + // at least fit a few blocks. This is essentially the initial + // window size which will determine how fast we can ramp up + // the send rate + int 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, diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 4dbe65b6c..41663c403 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4525,7 +4525,10 @@ namespace libtorrent int buffer_size_watermark = upload_rate * m_ses.settings().send_buffer_watermark_factor / 100; - if (buffer_size_watermark < 512) buffer_size_watermark = 512; + if (buffer_size_watermark < m_ses.settings().send_buffer_low_watermark) + { + buffer_size_watermark = m_ses.settings().send_buffer_low_watermark; + } else if (buffer_size_watermark > m_ses.settings().send_buffer_watermark) { buffer_size_watermark = m_ses.settings().send_buffer_watermark; diff --git a/src/session.cpp b/src/session.cpp index e662df931..29221b798 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -274,13 +274,17 @@ namespace libtorrent // the bandwidth delay product. Assuming an RTT // of 500 ms, and a send rate of 20 MB/s, the upper // limit should be 10 MB - set.send_buffer_watermark = 2 * 1024 * 1024; + set.send_buffer_watermark = 3 * 1024 * 1024; // put 1.5 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 = 150; + // always stuff at least 1 MiB down each peer + // pipe, to quickly ramp up send rates + set.send_buffer_low_watermark = 1 * 1024 * 1024; + // don't retry peers if they fail once. Let them // connect to us if they want to set.max_failcount = 1; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 2c5cb6f10..6aecadd0d 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -320,6 +320,7 @@ namespace aux { #endif TORRENT_SETTING(boolean, free_torrent_hashes) TORRENT_SETTING(boolean, upnp_ignore_nonrouters) + TORRENT_SETTING(integer, send_buffer_low_watermark) TORRENT_SETTING(integer, send_buffer_watermark) #ifndef TORRENT_NO_DEPRECATE TORRENT_SETTING(boolean, auto_upload_slots)