From owner-freebsd-fs@FreeBSD.ORG Wed Aug 31 07:38:38 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB8761065674; Wed, 31 Aug 2011 07:38:38 +0000 (UTC) (envelope-from lev@serebryakov.spb.ru) Received: from onlyone.friendlyhosting.spb.ru (onlyone.friendlyhosting.spb.ru [IPv6:2a01:4f8:131:60a2::2]) by mx1.freebsd.org (Postfix) with ESMTP id 67B108FC12; Wed, 31 Aug 2011 07:38:38 +0000 (UTC) Received: from lion.home.serebryakov.spb.ru (unknown [IPv6:2001:470:923f:1:6407:f3f9:7d93:d34c]) (Authenticated sender: lev@serebryakov.spb.ru) by onlyone.friendlyhosting.spb.ru (Postfix) with ESMTPA id 96D384AC58; Wed, 31 Aug 2011 11:38:36 +0400 (MSD) Date: Wed, 31 Aug 2011 11:38:33 +0400 From: Lev Serebryakov X-Priority: 3 (Normal) Message-ID: <485583919.20110831113833@serebryakov.spb.ru> To: Bob Friesenhahn In-Reply-To: References: <317753422.20110830231815@serebryakov.spb.ru> <201108302009.p7UK9CBQ085481@chez.mckusick.com> <103666698.20110831021404@serebryakov.spb.ru> <1693072185.20110831022933@serebryakov.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: quoted-printable Cc: freebsd-fs@freebsd.org Subject: Re: Very inconsistent (read) speed on UFS2 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 07:38:38 -0000 Hello, Bob. You wrote 31 =E0=E2=E3=F3=F1=F2=E0 2011 =E3., 2:40:07: >>> I'll try this experiment with mmap() and touching every 4096-th byte = of >>> mapped memory instead of read(2). >> Strange enough, it gives only 40-50MiB/s and results are very >> consistent. >> >> It really surprise me. I didn't think, that there will be so much >> difference, I was sure, that it will be almost equivalent speed. > FreeBSD does not seem to default to sequential read-ahead when memory > mapping is used with sequential page access. Try using madvise()=20 > with the MADV_SEQUENTIAL option and see if it helps. It were results with MADV_SEQUENTIAL. Code looks like this: (error checking is skipped here, but not in real code, of course): fd =3D open(fileName, O_RDONLY | O_DIRECT); buf =3D mmap(NULL, fileSize, PROT_READ, 0, fd, 0); madvise(buf, fileSize, MADV_SEQUENTIAL); gettimeofday(&start, NULL); for (rd =3D 0; rd < fileSize; rd +=3D 4096) c =3D buf[rd]; gettimeofday(&end, NULL); munmap(buf, fileSize); close(fd); > There are also MADV_WILLNEED, MADV_DONTNEED, and MADV_FREE. Careful > use of these options can help performance quite a lot when data is=20 > large compared to memory. It is too complex for simple linear read test :) --=20 // Black Lion AKA Lev Serebryakov