From owner-freebsd-questions@FreeBSD.ORG Fri Jun 6 03:09:59 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B05E1065670; Fri, 6 Jun 2008 03:09:59 +0000 (UTC) (envelope-from kirk@strauser.com) Received: from kanga.honeypot.net (kanga.honeypot.net [206.29.77.83]) by mx1.freebsd.org (Postfix) with ESMTP id 1A3498FC14; Fri, 6 Jun 2008 03:09:59 +0000 (UTC) (envelope-from kirk@strauser.com) Received: from localhost (localhost [127.0.0.1]) by kanga.honeypot.net (Postfix) with ESMTP id 7F5365DDEC6; Thu, 5 Jun 2008 22:09:28 -0500 (CDT) X-Virus-Scanned: amavisd-new at honeypot.net Received: from kanga.honeypot.net ([127.0.0.1]) by localhost (kanga.honeypot.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pJDDlS1fUdwQ; Thu, 5 Jun 2008 22:09:25 -0500 (CDT) Received: from [10.0.7.101] (wlan2-101.honeypot.net [10.0.7.101]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by kanga.honeypot.net (Postfix) with ESMTPSA id C4C4A5DE393; Thu, 5 Jun 2008 22:09:25 -0500 (CDT) Message-ID: <4848AA65.9060600@strauser.com> Date: Thu, 05 Jun 2008 22:09:25 -0500 From: Kirk Strauser User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Kris Kennaway References: <200806051508.29424.kirk@strauser.com> <4848523E.2010604@FreeBSD.org> <200806051617.54400.kirk@strauser.com> <484867E3.3070705@FreeBSD.org> <4848757B.30408@strauser.com> <48489222.7020501@FreeBSD.org> In-Reply-To: <48489222.7020501@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Poor read() performance, and I can't profile it 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: Fri, 06 Jun 2008 03:09:59 -0000 Kris Kennaway wrote: > I don't understand what you meant by "It's also doing a lot of lseek()s > to what is likely the current position anyway (example: seek to 0x00, > read 16 bytes, seek to 0x10, etc.)." then. I just meant that 16 was a smaller number than 4096 to use in an example. :-) But anyway, it looks like I was wrong. Each record in this test file is 144 bytes long, but instead of reading 144 bytes, it's reading 4096 bytes then seeking backward 3952 (4096-144) bytes to the start of the next record. For instance: 99823 dumprecspg CALL lseek(0x3,0x1c8,SEEK_SET,0) 99823 dumprecspg CALL read(0x3,0x8106000,0x1000) 99823 dumprecspg CALL lseek(0x3,0x258,SEEK_SET,0) 99823 dumprecspg CALL read(0x3,0x8106000,0x1000) 99823 dumprecspg CALL lseek(0x3,0x2e8,SEEK_SET,0) 99823 dumprecspg CALL read(0x3,0x8106000,0x1000) 99823 dumprecspg CALL lseek(0x3,0x378,SEEK_SET,0) 99823 dumprecspg CALL read(0x3,0x8106000,0x1000) Now, I know this is suboptimal. My code is a patch on another, longer-established project that I wasn't a part of, and I probably can't do a lot about it without a pretty major rewrite. Still, I can't believe the same code is *so* much faster on Linux. I'd also swear that this is a regression and that it used to run much faster on the same FreeBSD machine back when it was running 6.x, but I never bothered to benchmark it then because it didn't seem to be an issue. -- Kirk Strauser