From owner-freebsd-performance@FreeBSD.ORG Tue Sep 26 15:48:05 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 2818E16A4E7 for ; Tue, 26 Sep 2006 15:48:05 +0000 (UTC) (envelope-from mark@gaiahost.coop) Received: from biodiesel.gaiahost.coop (biodiesel.gaiahost.coop [64.95.78.120]) by mx1.FreeBSD.org (Postfix) with ESMTP id 573E343D83 for ; Tue, 26 Sep 2006 15:46:39 +0000 (GMT) (envelope-from mark@gaiahost.coop) Received: from gaiahost.coop (host-64-65-195-19.spr.choiceone.net [::ffff:64.65.195.19]) (AUTH: LOGIN mark@hubcapconsulting.com) by biodiesel.gaiahost.coop with esmtp; Tue, 26 Sep 2006 11:46:37 -0400 id 00794117.45194B5E.00007B0E Received: by gaiahost.coop (sSMTP sendmail emulation); Tue, 26 Sep 2006 11:46:44 -0400 Date: Tue, 26 Sep 2006 11:46:44 -0400 From: Mark Bucciarelli To: freebsd-performance@freebsd.org Message-ID: <20060926154643.GA3064@rabbit> Mail-Followup-To: freebsd-performance@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: 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: Tue, 26 Sep 2006 15:48:05 -0000 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? m