From owner-freebsd-fs@FreeBSD.ORG Tue Jun 27 23:04:06 2006 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0E5E16A403 for ; Tue, 27 Jun 2006 23:04:05 +0000 (UTC) (envelope-from ivoras@fer.hr) Received: from lara.cc.fer.hr (lara.cc.fer.hr [161.53.72.113]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57F2944B7B for ; Tue, 27 Jun 2006 23:04:05 +0000 (GMT) (envelope-from ivoras@fer.hr) Received: from [127.0.0.1] (localhost.cc.fer.hr [127.0.0.1]) by lara.cc.fer.hr (8.13.6/8.13.4) with ESMTP id k5RN3t9s087390; Wed, 28 Jun 2006 01:03:57 +0200 (CEST) (envelope-from ivoras@fer.hr) Message-ID: <44A1B958.4030204@fer.hr> Date: Wed, 28 Jun 2006 01:03:52 +0200 From: Ivan Voras User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050921) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Leo Huang References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-fs@freebsd.org Subject: Re: Is the fsync() fake on FreeBSD6.1? 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: Tue, 27 Jun 2006 23:04:06 -0000 Leo Huang wrote: > The result is followed: > OS Clients Result(queries per second) TPS(got from > iostat) > FreeBSD6.1 50 516.1 about 2000 > Debian3.1 50 49.8 about 200 > > I know that MySQL uses fsync() to flush both the data and log files at I tried to see the effects from fsync() with this little program: #include #include #include #define BUF_SIZE 512 #define COUNT 50000 int main() { int fd; char buf[BUF_SIZE]; int i; fd = open("test.file", O_CREAT|O_TRUNC|O_WRONLY, 0600); if (fd < 0) { printf("cannot open\n"); exit(1); } for (i = 0; i < COUNT; i++) { if (write(fd, buf, BUF_SIZE) != BUF_SIZE) { printf("error writing\n"); exit(1); } if (fsync(fd) < 0) { printf("error in fsync\n"); exit(1); } } close(fd); unlink("test.file"); return 0; But I see strange results with iostat. It shows 16KB transactions, ~2900 tps and 46 MB/s. On the other hand, the program runs for ~36 seconds, which gives ~1390 tps (this is a single desktop drive). Since 36 seconds of 46MB/s would result in a file 1.6 GB in size, while it's clearly 50000*512=25MB, iostat is lying. I think it's a too valuable tool to be lying. For what it's worth, gstat is also lying in the same way.