From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 8 22:52:49 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA65916A419 for ; Thu, 8 Nov 2007 22:52:49 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 4853913C4B0 for ; Thu, 8 Nov 2007 22:52:49 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.1/8.14.1) id lA8MqcGP071057; Thu, 8 Nov 2007 16:52:38 -0600 (CST) (envelope-from dan) Date: Thu, 8 Nov 2007 16:52:38 -0600 From: Dan Nelson To: Randall Hyde Message-ID: <20071108225238.GB22005@dan.emsphone.com> References: <000701c82253$b3a8c030$6302a8c0@pentiv> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000701c82253$b3a8c030$6302a8c0@pentiv> X-OS: FreeBSD 7.0-BETA1 User-Agent: Mutt/1.5.16 (2007-06-09) Cc: freebsd-hackers@freebsd.org Subject: Re: Some FreeBSD performance Issues X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Nov 2007 22:52:49 -0000 In the last episode (Nov 08), Randall Hyde said: > It appears that character-at-a-time file I/O is *exceptionally* slow. > Yes, I realize that when processing large files I really ought to be > doing block/buffered I/O to get the best performance, but for certain > library routines I've written it's been far more convenient to do > character-at-a-time I/O rather than deal with all the buffering > issues. In the past, while slower, this character-at-a-time paradigm > has provided reasonable, though not stellar, performance under > Windows and Linux. However, with the port to FreeBSD I'm seeing a > three-orders-of-magnitude performance loss. Here's my little test > program: [...] > The "fileio.open" call is basically a bsd.open( "socket.h", bsd.O_RDONLY ); > API call. The socket.h file is about 19K long (it's from the FreeBSD > include file set). In particular, I would draw your attention to the first > two tests that do character-at-a-time I/O. The difference in performance What timings does "dd if=/usr/include/sys/socket.h of=/dev/null ibs=1 obs=64k" report? It takes about .4 sec on my non-idle dual pIII-900 system. Try truss'ing your program as it runs; maybe the program is doing some extra syscalls you aren't aware of? -- Dan Nelson dnelson@allantgroup.com