From patchwork Thu Apr 5 22:43:22 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Skawina X-Patchwork-Id: 12448 Received: from mx10.go2.pl ([193.17.41.74] helo=poczta.o2.pl) by www.linuxtv.org with esmtp (Exim 4.50) id 1HZagL-0004rl-SV for vdr@linuxtv.org; Fri, 06 Apr 2007 00:43:53 +0200 Received: from poczta.o2.pl (mx10.go2.pl [127.0.0.1]) by poczta.o2.pl (Postfix) with ESMTP id EFA5F58022 for ; Fri, 6 Apr 2007 00:43:22 +0200 (CEST) Received: from dkh242.neoplus.adsl.tpnet.pl (dkh242.neoplus.adsl.tpnet.pl [83.24.11.242]) by poczta.o2.pl (Postfix) with ESMTP for ; Fri, 6 Apr 2007 00:43:22 +0200 (CEST) Received: (qmail 1184 invoked from network); 5 Apr 2007 22:43:22 -0000 Received: from unknown (HELO ?172.19.43.221?) (172.19.43.221) by 172.19.43.250 with SMTP; 5 Apr 2007 22:43:22 -0000 Message-ID: <46157B8A.2030801@o2.pl> Date: Fri, 06 Apr 2007 00:43:22 +0200 From: Artur Skawina User-Agent: Thunderbird 3.0a1 (X11/20070320) MIME-Version: 1.0 To: VDR Mailing List X-Enigmail-Version: 0.95b Cc: Sascha Volkenandt Subject: [vdr] [PATCH] limit streamdev client's ringbuffer timeouts to more sane values X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2007 22:43:54 -0000 Status: O X-Status: X-Keywords: X-UID: 12620 Well, the streamdev-client reads data from a ringbuffer and when there isn't anything to read it tries to sleep for 1us and loops. This wasn't a problem when the timer resolution was in the 1000..10000us range (1000..100Hz); the usleep(1) call slept for one or more milliseconds. With the high-res timers in kernel 2.6.21+ usleep(1) is no longer treated as usleep(10000) and the streamdev client is almost unusable; it uses most of the cpu and causes hundreds of thousands context switches per second. This gets rid of the almost-busy-loop. artur diff -urNp streamdev.org/client/filter.c streamdev/client/filter.c --- streamdev.org/client/filter.c 2005-11-06 17:43:58.000000000 +0100 +++ streamdev/client/filter.c 2007-04-05 23:25:11.000000000 +0200 @@ -57,6 +57,7 @@ cStreamdevFilters::cStreamdevFilters(voi cThread("streamdev-client: sections assembler") { m_Active = false; m_RingBuffer = new cRingBufferLinear(MEGABYTE(1), TS_SIZE * 2, true); + m_RingBuffer->SetTimeouts(10, 10); Start(); } @@ -111,8 +112,7 @@ void cStreamdevFilters::Action(void) { } } m_RingBuffer->Del(TS_SIZE); - } else - usleep(1); + } } }