From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Aug 19 10:10:10 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9AC73106566B for ; Sun, 19 Aug 2012 10:10:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 56C298FC0A for ; Sun, 19 Aug 2012 10:10:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q7JAAATx015029 for ; Sun, 19 Aug 2012 10:10:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q7JAAA3E015027; Sun, 19 Aug 2012 10:10:10 GMT (envelope-from gnats) Resent-Date: Sun, 19 Aug 2012 10:10:10 GMT Resent-Message-Id: <201208191010.q7JAAA3E015027@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Yamagi Burmeister Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D9C88106564A for ; Sun, 19 Aug 2012 10:05:31 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id C54338FC0A for ; Sun, 19 Aug 2012 10:05:31 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q7JA5Vej057195 for ; Sun, 19 Aug 2012 10:05:31 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q7JA5VgP057194; Sun, 19 Aug 2012 10:05:31 GMT (envelope-from nobody) Message-Id: <201208191005.q7JA5VgP057194@red.freebsd.org> Date: Sun, 19 Aug 2012 10:05:31 GMT From: Yamagi Burmeister To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/170766: High CPU load caused by net-p2p/libtorrent X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Aug 2012 10:10:10 -0000 >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: