Date: Mon, 26 Nov 2001 16:07:48 -0800 (PST) From: Matthew Dillon <dillon@apollo.backplane.com> To: David Greenman <dg@root.com> Cc: Sheldon Hearn <sheldonh@starjuice.net>, Kirk McKusick <mckusick@beastie.mckusick.com>, freebsd-arch@FreeBSD.ORG Subject: Re: Using a larger block size on large filesystems Message-ID: <200111270007.fAR07mZ85526@apollo.backplane.com> References: <200111241845.fAOIjM377587@apollo.backplane.com> <34669.1006787273@axl.seasidesoftware.co.za> <20011126102144.A68993@nexus.root.com>
next in thread | previous in thread | raw e-mail | index | archive | help
:
:>Do you agree with me that we'd benefit the largest number of
:>installations by targetting applications with MTA-like access on small
:>files?
:
: Given the radial density of modern disk drives, the amount of time needed
:to read an additional 8KB in a random access scenario is quite trivial -
:usually less than .25ms, making the total percentage increase in access
:time small enough to not be a significant concern.
:
:-DG
:
:David Greenman
Not to mention the increased memory capacity in modern machines.
When you put it together, we ought to see only small differences
in regards to random seek+read performance.
apollo:/src/misc# ./rs /dev/da0s1c 4096
calculating size using seek/read search...24461946880 bytes
Random seek/read test file size 23328.73MB blockSize 4.00KB
172.00 seek+read/sec
174.07 seek+read/sec
176.03 seek+read/sec
173.59 seek+read/sec
apollo:/src/misc# ./rs /dev/da0s1c 8192
calculating size using seek/read search...24461942784 bytes
Random seek/read test file size 23328.73MB blockSize 8.00KB
169.70 seek+read/sec
171.59 seek+read/sec
168.59 seek+read/sec
146.61 seek+read/sec
apollo:/src/misc# ./rs /dev/da0s1c 16384
calculating size using seek/read search...24461934592 bytes
Random seek/read test file size 23328.72MB blockSize 16.00KB
159.41 seek+read/sec
160.67 seek+read/sec
164.88 seek+read/sec
160.14 seek+read/sec
I've included the program below.. it would be cool if people
with RAID systems could run the same tests.
-Matt
Matthew Dillon
<dillon@backplane.com>
/*
* RANDSEEK.C
*
* randseek file/device [blocksize]
*/
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void startTiming(void);
static long stopTiming(void);
static off_t sizeSearch(int fd, int blockSize, char *buf);
int
main(int ac, char **av)
{
int fd;
int blockSize = 8192;
int load;
int count;
struct stat st;
off_t size;
char *buf;
srandom(1); /* use same sequence every time */
if (ac == 1) {
fprintf(stderr, "%s file_or_device [blocksize]\n", av[0]);
exit(1);
}
if (ac > 2)
blockSize = strtol(av[2], NULL, 0);
if ((buf = malloc(blockSize)) == NULL) {
fprintf(stderr, "Unable to malloc block size\n");
exit(1);
}
if ((fd = open(av[1], O_RDONLY)) < 0) {
perror("open");
exit(1);
}
size = lseek(fd, 0L, 2);
if (size <= 0) {
if (fstat(fd, &st) == 0)
size = st.st_size;
}
if (size <= 0) {
printf("calculating size using seek/read search...");
size = sizeSearch(fd, blockSize, buf);
printf("%qd bytes\n", (quad_t)size);
}
size = size - size % blockSize;
if (size <= 0 || blockSize <= 0 || blockSize > size) {
fprintf(stderr, "Unusable file or block size\n");
exit(1);
}
printf(
"Random seek/read test file size %6.2fMB blockSize %6.2fKB\n",
(double)size / (1024.0 * 1024.0),
(double)blockSize / 1024.0
);
count = load = 0;
startTiming();
for (;;) {
off_t off = (random() % size / blockSize) * blockSize;
lseek(fd, off, 0);
read(fd, buf, blockSize);
if (load == 0) {
/*
* Calculatin timing window (approx 3 seconds)
*/
++count;
if (count % 10 == 0 && stopTiming() > 3000000) {
load = count;
count = 0;
startTiming();
}
} else {
/*
* Compute seek+read rate for timing window
*/
if (++count == load) {
int us = stopTiming();
printf(
"%6.2f seek+read/sec\n",
(double)load / (double)us * 1000000.0
);
fflush(stdout);
count = 0;
startTiming();
}
}
}
}
static struct timeval Tv1;
static struct timeval Tv2;
static void
startTiming(void)
{
gettimeofday(&Tv1, NULL);
}
static long
stopTiming(void)
{
gettimeofday(&Tv2, NULL);
return ((Tv2.tv_usec + 1000000 - Tv1.tv_usec) + (Tv2.tv_sec - Tv1.tv_sec - 1) * 1000000);
}
static off_t
sizeSearch(int fd, int blockSize, char *buf)
{
off_t beg = 4096;
off_t off = 0;
for (;;) {
lseek(fd, beg, 0);
if (read(fd, buf, blockSize) != blockSize)
break;
beg <<= 1;
}
off = beg;
beg = beg >> 1;
while (beg != off) {
off_t mid = (beg + off) / 2;
mid -= mid % blockSize;
lseek(fd, mid, 0);
if (read(fd, buf, blockSize) == blockSize) {
beg = mid;
if (mid + blockSize == off)
break;
} else {
off = mid;
}
}
return(off);
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111270007.fAR07mZ85526>
