From owner-freebsd-questions@FreeBSD.ORG Tue Aug 2 18:45:33 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 93E3616A41F for ; Tue, 2 Aug 2005 18:45:33 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 34D2943D45 for ; Tue, 2 Aug 2005 18:45:33 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from localhost (localhost [127.0.0.1]) by pi.codefab.com (Postfix) with ESMTP id 8A95B5E89; Tue, 2 Aug 2005 14:45:32 -0400 (EDT) Received: from pi.codefab.com ([127.0.0.1]) by localhost (pi.codefab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 61412-04; Tue, 2 Aug 2005 14:45:31 -0400 (EDT) Received: from [192.168.1.3] (pool-68-161-54-113.ny325.east.verizon.net [68.161.54.113]) by pi.codefab.com (Postfix) with ESMTP id 4937E5C39; Tue, 2 Aug 2005 14:45:30 -0400 (EDT) Message-ID: <42EFBF4A.2010209@mac.com> Date: Tue, 02 Aug 2005 14:45:30 -0400 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.11) Gecko/20050801 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd@celestial.com References: <200508021537.26986.victor@vmpbg.com> <20050802173421.GA34971@alexis.mi.celestial.com> In-Reply-To: <20050802173421.GA34971@alexis.mi.celestial.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at codefab.com Cc: victor@vmpbg.com, freebsd-questions@freebsd.org Subject: Re: polling decreases throughput ~50% X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2005 18:45:33 -0000 Bill Campbell wrote: > On Tue, Aug 02, 2005, Victor Semionov wrote: [ ... ] >>I was uploading some large file to my neighbor's windows box. With polling >>disabled, the transfer rate was 8 MB/s and CPU usage was 90%. I turned on >>polling with sysctl and CPU usage decreased to 50%, which I expected, but >>also the transfer rate dropped to 4.5 MB/s, about half. The numbers are >>approximate. The interface is a RealTek (rl driver). No background jobs were >>running. kern.polling.* all defaults. What is kern.hz set to? Does increasing it improve throughput? >> Why is that? I thought polling should decrease CPU usage by avoiding too many >> context switches when a hw irq is generated frequently, but it shouldn't make >> the transfer slower if there are no other jobs running. You have to poll often enough to keep the pipe full, otherwise your max throughput can be limited. Also, rl hardware isn't the greatest and probably requires a lot more CPU than a device with working buffer/DMA design. > I certainly don't claim to be an expert on this subject so take this with a > grain of salt. > > Interrupts were originally created to eliminate the need for polling > allowing processes to sleep until an interrupt occurs rather than having > the process in a loop testing to see if any input is ready or the device is > available for further work. Blocking was created to eliminate the need for polling/sitting in a loop testing a condition. Interrupts were created to take the CPU away from normal processing in order to attend a high-priority, time-critical condition or signal which can't wait. A good serial chip/UART, or a NIC receiving packets, shouldn't fire an interrupt just because a character/packet came in, they should fire an interrupt when their SILO/buffer is getting full or has some data which hasn't been serviced in a while. ("Interrupt coalescing") -- -Chuck