Date: Wed, 28 Jun 2006 01:03:52 +0200 From: Ivan Voras <ivoras@fer.hr> To: Leo Huang <leo.huang.gd@gmail.com> Cc: freebsd-fs@freebsd.org Subject: Re: Is the fsync() fake on FreeBSD6.1? Message-ID: <44A1B958.4030204@fer.hr> In-Reply-To: <a0cd7c070606270032h3a42de6ahf21cd11abedb6400@mail.gmail.com> References: <a0cd7c070606270032h3a42de6ahf21cd11abedb6400@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdlib.h> #include <stdio.h> #include <fcntl.h> #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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44A1B958.4030204>