From owner-freebsd-questions@FreeBSD.ORG Fri Jun 6 10:48:18 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 F2474106566B for ; Fri, 6 Jun 2008 10:48:18 +0000 (UTC) (envelope-from kris@FreeBSD.org) Received: from weak.local (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CCB238FC1A; Fri, 6 Jun 2008 10:48:17 +0000 (UTC) (envelope-from kris@FreeBSD.org) Message-ID: <484915F1.10606@FreeBSD.org> Date: Fri, 06 Jun 2008 12:48:17 +0200 From: Kris Kennaway User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: Kirk Strauser 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> <4848AA65.9060600@strauser.com> In-Reply-To: <4848AA65.9060600@strauser.com> 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 10:48:19 -0000 Kirk Strauser wrote: > 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. Can you confirm or provide a code sample? What does strace show on Linux? Kris