diff --git a/docs/manual.rst b/docs/manual.rst index 005403f05..12b52d4fe 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3896,6 +3896,7 @@ session_settings bool broadcast_lsd; bool ignore_resume_timestamps; bool anonymous_mode; + int tick_interval; }; ``user_agent`` this is the client identification to the tracker. @@ -4548,6 +4549,12 @@ when this setting is enabled. If you're using I2P, it might make sense to enable anonymous mode as well. +``tick_interval`` specifies the number of milliseconds between internal +ticks. This is the frequency with which bandwidth quota is distributed to +peers. It should not be more than one second (i.e. 1000 ms). Setting this +to a low value (around 100) means higher resolution bandwidth quota distribution, +setting it to a higher value saves CPU cycles. + pe_settings =========== diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 3c4e56107..6fcf193b8 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -213,6 +213,7 @@ namespace libtorrent , broadcast_lsd(false) , ignore_resume_timestamps(false) , anonymous_mode(false) + , tick_interval(100) {} // this is the user agent that will be sent to the tracker @@ -824,6 +825,10 @@ namespace libtorrent // mode is assumed to be combined with using a proxy for all your // traffic. With this option, your true IP address will not be exposed bool anonymous_mode; + + // the number of milliseconds between internal ticks. Should be no + // more than one second (i.e. 1000). + int tick_interval; }; #ifndef TORRENT_DISABLE_DHT diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 229513571..d806f9a06 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -318,6 +318,7 @@ namespace aux { TORRENT_SETTING(boolean, broadcast_lsd) TORRENT_SETTING(boolean, ignore_resume_timestamps) TORRENT_SETTING(boolean, anonymous_mode) + TORRENT_SETTING(integer, tick_interval) }; #undef TORRENT_SETTING @@ -722,7 +723,7 @@ namespace aux { url_random((char*)&m_peer_id[print.length()], (char*)&m_peer_id[0] + 20); - m_timer.expires_from_now(milliseconds(100), ec); + m_timer.expires_from_now(milliseconds(m_settings.tick_interval), ec); m_timer.async_wait(boost::bind(&session_impl::on_tick, this, _1)); int delay = (std::max)(m_settings.local_service_announce_interval @@ -1903,7 +1904,7 @@ namespace aux { } error_code ec; - m_timer.expires_at(now + milliseconds(100), ec); + m_timer.expires_at(now + milliseconds(m_settings.tick_interval), ec); m_timer.async_wait(bind(&session_impl::on_tick, this, _1)); m_download_rate.update_quotas(now - m_last_tick);