Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Aug 2012 10:05:31 GMT
From:      Yamagi Burmeister <yamagi@yamagi.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/170766: High CPU load caused by net-p2p/libtorrent
Message-ID:  <201208191005.q7JA5VgP057194@red.freebsd.org>
Resent-Message-ID: <201208191010.q7JAAA3E015027@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208191005.q7JA5VgP057194>