Index: Bonnie.c --- Bonnie.c.orig 1996-08-28 18:23:49 +0200 +++ Bonnie.c 2004-08-22 11:45:20 +0200 @@ -179,7 +179,7 @@ if (bufindex == Chunk / IntSize) bufindex = 0; buf[bufindex++]++; - if (lseek(fd, (off_t) -words, 1) == -1) + if (lseek(fd, -words, 1) == -1) io_error("relative lseek(2)"); if (write(fd, (char *) buf, words) == -1) io_error("re write(2)"); @@ -288,6 +288,7 @@ { /* child process */ /* set up and wait for the go-ahead */ + close(0); close(seek_feedback[0]); close(seek_control[1]); newfile(name, &fd, &stream, 0); @@ -303,7 +304,12 @@ /* loop until we read a 0 ticket back from our parent */ while(seek_tickets[0]) { /* until Mom says stop */ - doseek((long) (random() % (size / Chunk)), fd, + off_t seekto; + if (size < ((off_t)1 << 32)) + seekto = random() % (size / Chunk); + else + seekto = ((off_t)random() << 32 + random()) % (size / Chunk); + doseek(seekto, fd, ((lseek_count++ % UpdateSeek) == 0)); if (read(seek_control[0], seek_tickets, 1) != 1) io_error("read ticket"); @@ -413,7 +419,7 @@ printf("K/sec %%CPU K/sec %%CPU K/sec %%CPU K/sec %%CPU K/sec "); printf("%%CPU /sec %%CPU\n"); - printf("%-8.8s %4d ", machine, size / (1024 * 1024)); + printf("%-8.8s %4ld ", machine, (long)(size / (1024 * 1024))); printf("%5d %4.1f %5d %4.1f %5d %4.1f ", (int) (((double) size) / (delta[(int) Putc][Elapsed] * 1024.0)), delta[(int) Putc][CPU] / delta[(int) Putc][Elapsed] * 100.0, @@ -458,7 +464,7 @@ usage() { fprintf(stderr, - "usage: Bonnie [-d scratch-dir] [-s size-in-Mb] [-html] [-m machine-label]\n"); + "usage: bonnie [-d scratch-dir] [-s size-in-Mb] [-html] [-m machine-label]\n"); exit(1); } @@ -529,7 +535,7 @@ { char buf[Chunk]; - sprintf(buf, "Bonnie: drastic I/O error (%s)", message); + sprintf(buf, "\nBonnie: drastic I/O error (%s)", message); perror(buf); exit(1); } @@ -568,7 +574,7 @@ /* touch a word */ buf[((int) random() % (size/IntSize - 2)) + 1]--; - if (lseek(fd, (long) probe, 0) != probe) + if (lseek(fd, probe, 0) != probe) io_error("lseek in doseek update"); if (write(fd, (char *) buf, size) == -1) io_error("write in doseek"); Index: bonnie.1 --- bonnie.1.orig 1996-08-29 03:42:42 +0200 +++ bonnie.1 2004-08-22 11:43:30 +0200 @@ -1,92 +1,69 @@ -.\"------- -.\" Man page portability notes -.\" -.\" These are some notes on conventions to maintain for greatest -.\" portability of this man page to various other versions of -.\" nroff. -.\" -.\" When you want a \ to appear in the output, use \e in the man page. -.\" (NOTE this comes up in the rc grammar, where to print out '\n' the -.\" man page must contain '\en'.) -.\" -.\" Evidently not all versions of nroff allow the omission of the -.\" terminal " on a macro argument. Thus what could be written -.\" -.\" .Cr "exec >[2] err.out -.\" -.\" in true nroffs must be written -.\" -.\" .Cr "exec >[2] err.out" -.\" -.\" instead. -.\" -.\" Use symbolic font names (e.g. R, I, B) instead of the standard -.\" font positions 1, 2, 3. Note that for Xf to work the standard -.\" font names must be single characters. -.\" -.\" Note that sentences should end at the end of a line. nroff and -.\" troff will supply the correct intersentence spacing, but only if -.\" the sentences end at the end of a line. Explicit spaces, if given, -.\" are apparently honored and the normal intersentence spacing is -.\" supressed. -.\" -.\" DaviD W. Sanderson -.\"------- -.\" Dd distance to space vertically before a "display" -.\" These are what n/troff use for interparagraph distance -.\"------- -.if t .nr Dd .4v -.if n .nr Dd 1v -.\"------- -.\" Sp space down the interparagraph distance -.\"------- -.de Sp -.sp \\n(Ddu -.. -.\"------- -.\" Ds begin a display, indented .5 inches from the surrounding text. -.\" -.\" Note that uses of Ds and De may NOT be nested. -.\"------- -.de Ds -.Sp -.in +0.5i -.nf -.. -.\"------- -.\" De end a display (no trailing vertical spacing) -.\"------- -.de De -.fi -.in -.. -.TH Bonnie 1 "2.0.6" Textuality -.SH NAME -Bonnie - File system benchmark -.SH "SYNOPSIS" -.B Bonnie -.RI "[-d\ scratch-dir]" -.RI "[-html]" -.RI "[-m\ machine-label]" -.RI "[-s\ size-in-Mb]" -.SH "OPTIONS" -.PP - -d scratch-dir : Write scratch file in named directory (default: ".") - -html : Generate HTML output - -m machine-label : use to label report - -s size-in-Mb : how many Mb to use for testing (default: 100) -.\"------- -.SH "DESCRIPTION" -.\"------- -.I Bonnie -measures the performance of UNIX filesystem operations. -For details, see http://www.textuality.com/bonnie/ -.\"------- -.SH "AUTHOR" -.\"------- -.I Bonnie -was written by Tim Bray, -(tbray@textuality.com), -.I Bonnie -is copyrighted 1990-1996 by Tim Bray. -For details, see http://www.textuality.com/bonnie/copyright.html +.\" $FreeBSD: ports/benchmarks/bonnie/files/bonnie.1,v 1.1 2002/08/27 15:53:51 obrien Exp $ +.\" The following requests are required for all man pages. +.Dd May 18, 1995 +.Os UNIX +.Dt BONNIE 1 +.Sh NAME +.Nm bonnie +.Nd Performance Test of Filesystem I/O +.Sh SYNOPSIS +.Nm bonnie +.Op Fl d Ar scratch-dir +.Op Fl s Ar size-in-MB +.Op Fl m Ar machine-label + +.Sh DESCRIPTION +.Nm Bonnie +tests the speed of file I/O from standard C library calls. +It reads and writes 8KB blocks to find the maximum sustained +data rate (usually limited by the drive or controller) and additionally +rewrites the file (better simulating normal operating conditions and +quite dependent on drive and OS optimisations). + +The per character read and write tests are generally limited by CPU speed +only on current generation hardware. It takes some 35 SPECint92 to read +or write a file at a rate of 1MB/s using getc() and putc(). + +The seek test results depend on the buffer cache size, since the fraction +of disk blocks that fits into the buffer cache will be found without any +disk operation and will contribute zero seek time samples. +(See +.Sx BUGS +below.) + +.Sh OPTIONS +.Bl -tag -width indent +.It Fl d Ar scratch-dir +Specify the directory where the test file gets written. The default +is the current directory. Make sure there is sufficient free space +available on the partition this directory resides in. +.It Fl s Ar size-in-MB +Specify the size of the test file in MByte. This much space must be +available for the tests to complete. +.It Fl m Ar machine-label +Specify a label to be written in the first column of the result table. +.El + +.Sh SEE ALSO +.Xr iozone 1 , +.Xr iostat 8 + +.Sh AUTHOR +.Nm Bonnie +was written by Tim Bray . + +.Sh BUGS +.Nm Bonnie +tries hard to measure disk performance and not the quality of the +buffer cache implementation. In merged buffer caches common today, +the buffer cache size is often only limited by total RAM on an otherwise +unloaded system. Be sure to use a file at least twice at large as +available RAM to protect against artificially high results. + +There is no way to keep the buffer cache from increasing the reported +seek rate. This is because the fraction of accesses corresponding to the +amount of the file cached, will be done without seeks. +If your buffer cache is half the size of the file used, then half the +requests will be satisfied immediately, and and the seek rate printed +will be twice the actual value. +