ports/170766: High CPU load caused by net-p2p/libtorrent
Yamagi Burmeister
yamagi at yamagi.org
Sun Aug 19 10:10:10 UTC 2012
>Number: 170766
>Category: ports
>Synopsis: High CPU load caused by net-p2p/libtorrent
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Aug 19 10:10:08 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Yamagi Burmeister
>Release: FreeBSD 9.1-RC1
>Organization:
>Environment:
FreeBSD happy.home.yamagi.org 9.1-RC1 FreeBSD 9.1-RC1 #0 r239211M: Sun Aug 12 18:06:42 CEST 2012 root at happy.home.yamagi.org:/usr/obj/usr/src/sys/HAPPY amd64
>Description:
As noted in ports/169734 net-p2p/libtorrent ha a bug, causing it to generate a lot of CPU load on FreeBSD. The problem is easy to fix and an pull request has been send upstream: https://github.com/rakshasa/libtorrent/pull/21
>How-To-Repeat:
Use a consumer of net-p2p/libtorrent (for example net-p2p/rtorrent) on FreeBSD. After some seconds it's CPU load will rise up to several hundred percent.
>Fix:
As said above, a pull request has been send upstream: https://github.com/rakshasa/libtorrent/pull/21 I request to add the attached patch (exatly the same change as in the pull request) to net-p2p/libtorrent until the problem is solved upstream.
Patch attached with submission follows:
--- src/torrent/utils/thread_base.cc.orig
+++ src/torrent/utils/thread_base.cc
@@ -88,6 +88,8 @@ thread_base::stop_thread_wait() {
void
thread_base::interrupt() {
+ int sleep_length = 0;
+
__sync_fetch_and_or(&m_flags, flag_no_timeout);
while (is_polling() && has_no_timeout()) {
@@ -96,7 +98,8 @@ thread_base::interrupt() {
if (!(is_polling() && has_no_timeout()))
return;
- usleep(0);
+ usleep(sleep_length);
+ sleep_length = std::min(sleep_length + 50, 1000);
}
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list