From abfc92de356fb837f4e780a73bf4ddabc82dcba7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 6 Feb 2010 07:39:45 +0000 Subject: [PATCH] added performance warning if there are too many optimistic unchoke slots --- docs/manual.rst | 3 ++- include/libtorrent/alert_types.hpp | 9 ++++++++- src/alert.cpp | 3 ++- src/session_impl.cpp | 13 +++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index bc6043f65..971fa6350 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -5625,7 +5625,8 @@ upload or download rate performance. outstanding_request_limit_reached, upload_limit_too_low, download_limit_too_low, - send_buffer_watermark_too_low + send_buffer_watermark_too_low, + too_many_optimistic_unchoke_slots }; performance_warning_t warning_code; diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index f5eb1d156..2ecbe4fa5 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -187,7 +187,14 @@ namespace libtorrent outstanding_request_limit_reached, upload_limit_too_low, download_limit_too_low, - send_buffer_watermark_too_low + send_buffer_watermark_too_low, + too_many_optimistic_unchoke_slots + + + + + + }; performance_alert(torrent_handle const& h diff --git a/src/alert.cpp b/src/alert.cpp index be6ca07d1..09816d190 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -112,7 +112,8 @@ namespace libtorrent { "max outstanding piece requests reached", "upload limit too low (download rate will suffer)", "download limit too low (upload rate will suffer)", - "send buffer watermark too low (upload rate will suffer)" + "send buffer watermark too low (upload rate will suffer)", + "too many optimistic unchoke slots" }; return torrent_alert::message() + ": performance warning: " diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0dcd7ae5a..fc3a047ca 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1070,6 +1070,13 @@ namespace aux { m_disk_thread.add_job(j); } + if (m_allowed_upload_slots <= m_settings.num_optimistic_unchoke_slots / 2) + { + if (m_alerts.should_post()) + m_alerts.post_alert(performance_alert(torrent_handle() + , performance_alert::too_many_optimistic_unchoke_slots)); + } + if (!s.auto_upload_slots) m_allowed_upload_slots = m_max_uploads; // replace all occurances of '\n' with ' '. std::string::iterator i = m_settings.user_agent.begin(); @@ -3210,6 +3217,12 @@ namespace aux { if (m_max_uploads == limit) return; m_max_uploads = limit; m_allowed_upload_slots = limit; + if (m_allowed_upload_slots <= m_settings.num_optimistic_unchoke_slots / 2) + { + if (m_alerts.should_post()) + m_alerts.post_alert(performance_alert(torrent_handle() + , performance_alert::too_many_optimistic_unchoke_slots)); + } } void session_impl::set_max_connections(int limit)