From owner-freebsd-performance@FreeBSD.ORG Wed Sep 27 16:49:30 2006 Return-Path: X-Original-To: freebsd-performance@freebsd.org Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D5C5D16A47B for ; Wed, 27 Sep 2006 16:49:30 +0000 (UTC) (envelope-from anderson@centtech.com) Received: from mh2.centtech.com (moat3.centtech.com [64.129.166.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id DF23243D45 for ; Wed, 27 Sep 2006 16:49:29 +0000 (GMT) (envelope-from anderson@centtech.com) Received: from [10.177.171.220] (neutrino.centtech.com [10.177.171.220]) by mh2.centtech.com (8.13.1/8.13.1) with ESMTP id k8QGdUUY015495 for ; Tue, 26 Sep 2006 11:39:30 -0500 (CDT) (envelope-from anderson@centtech.com) Message-ID: <451957C2.90701@centtech.com> Date: Tue, 26 Sep 2006 11:39:30 -0500 From: Eric Anderson User-Agent: Thunderbird 1.5.0.7 (X11/20060923) MIME-Version: 1.0 To: freebsd-performance@freebsd.org References: <20060926154643.GA3064@rabbit> In-Reply-To: <20060926154643.GA3064@rabbit> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.87.1/1946/Tue Sep 26 08:18:37 2006 on mh2.centtech.com X-Virus-Status: Clean Subject: Re: Why are disk writes so slow? X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Sep 2006 16:49:30 -0000 On 09/26/06 10:46, Mark Bucciarelli wrote: > I am reading Richard Stevens' "Advanced Programming in the UNIX > Environment," a most excellent book. > > Out of curiosity, I tried his I/O efficiency program on my IBM > A30 Thinkpad, running 6.0-RELEASE with default tuning parameters. > The test program reads file on stdin and writes to stdout, and > you modify bufsize to watch how time changes. > > As in his example (with a bufsize of 8192), > > time ./a.out < 1.5M-testfile > /dev/null > > runs five times faster than (clock time) > > time ./a.out < 1.5M-testfile > /a.out.out > > Can someone explain to me why writing is five times as slow as > writing? What's going on in the computer? > > The file is not O_SYNC, so it can't be validating the data on the > disk. > > Later in the same chapter, he shows the impact of O_SYNC flag. I > re-ran this experiment too, and while everything is two orders of > magnitude faster than his times in the book, the relative speed > of writing with O_SYNC is three times slower. > > 1993 2006 > ----- ---- > normal write 2.3s .023s > O_SYNC 13.4s .364s > slowdow factor 5.8 15.8 > > Is this all b/c disks are so much larger? It's probably because of caching on the disk. The normal write goes in/out of the on-disk cache, the O_SYNC may be forced to go to the platters. Also, if you didn't already, you should run the test many times, umounting/mounting the filesystem in question in between each test. Also, I recommend using a block device, instead of a file on a filesystem, since the filesystem could allocate blocks for the file differently each time, causing varying results. Eric -- ------------------------------------------------------------------------ Eric Anderson Sr. Systems Administrator Centaur Technology Anything that works is better than anything that doesn't. ------------------------------------------------------------------------