From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199709171309.PAA03916@zebara.axis.se> Date: Wed, 17 Sep 1997 15:09:41 +0200 (MET DST) From: Ronny Ranerup Subject: Re: Problems with slow EIDE disk / slow system time Stefan Schroepfer> >Yes: hdparm does report a higher read rate (using option '-t') >after setting some flags. >*BUT* simply counting seconds during a > $ hdparm -T /dev/hda # to avoid caching artifacts > $ hdparm -t /dev/hda # perform timings of device reads >on an otherwise idle system will show you that disk throughput >is not as fast as hdparm wants to tell you. >In fact, only the OS's clock runs slower during disk I/O, as you >can see if you do a > $ clock -u -A -r; date # '-A' if ARC console >before and after the two hdparm calls. > >> Is there a possibility to get both, a fast disk throughput and a >> accurate system time? > >In my opinion: no. I think it is only possible to slow down system >time, but not to get fast EIDE disk throughput. Try this, reads directly from the device. Change MEGS to how many megs ram you have, used for flushing the cache... /ronny@axis.com/Ronny Ranerup/Axis Communications AB/http://www.axis.com --- #include #include #include #include #include #include /* Set to how many megs ram you have */ #define MEGS 128 #define BYTES (1024*5000) int main (int argc, char *argv[]) { int fd; char *buf; int i; struct timeval start; struct timeval end; struct timeval diff; long int usec = 0; char *foo; int times; int BUFSIZE = 1024*1000; int db = 0; float min = 100000000; float max = 0; float average = 0; float mbps; int reads = 0; if (argc != 2) { printf("Needs file/device as argument\n"); exit(1); } if ((fd = open(argv[1], O_RDONLY)) == -1) { perror("open failed"); exit(1); } foo = (char*) malloc(1024*1000*MEGS); printf("Flushing ram...\n"); for (i = 0; i < 1024*1000*64; i+=1024) { foo[i] = 4; } free(foo); printf("...done\n"); for (BUFSIZE = 1024; BUFSIZE <= BYTES; BUFSIZE*=2) { if (db) printf("Getting buffer into memory...\n"); buf = (char*) malloc(BUFSIZE); for (i = 0; i != BUFSIZE-1; i++) { buf[i] = 0; } if (db) printf("...done\n"); gettimeofday(&start, NULL); gettimeofday(&end, NULL); times = BYTES/BUFSIZE; printf("%d bytes per read, %d times = %d bytes.\n", BUFSIZE, times, times*BUFSIZE); if (db) printf("start\n"); gettimeofday(&start, NULL); for (i = 0; i != times; i++) { if (read(fd, buf, BUFSIZE) != BUFSIZE) { perror("read failed"); exit(1); } } gettimeofday(&end, NULL); if (db) printf("end\n"); timeval_subtract(&diff, &end, &start); if (db) printf ("%ldsecs %ldusecs\n", diff.tv_sec, diff.tv_usec); usec = diff.tv_sec * 1000000 + diff.tv_usec; mbps = (float)(times*BUFSIZE)/usec; printf("%d bytes in %ld usecs. %fMB/s\n\n", times*BUFSIZE, usec, mbps); if (mbps > max) max = mbps; if (mbps < min) min = mbps; average += mbps; reads++; } free(buf); printf("MB/s min:%f, max:%f, average:%f\n", min, max, average/reads); } int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y) { /* Perform the carry for the later subtraction by updating Y. */ if (x->tv_usec < y->tv_usec) { int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; y->tv_usec -= 1000000 * nsec; y->tv_sec += nsec; } if (x->tv_usec - y->tv_usec > 1000000) { int nsec = (y->tv_usec - x->tv_usec) / 1000000; y->tv_usec += 1000000 * nsec; y->tv_sec -= nsec; } /* Compute the time remaining to wait. `tv_usec' is certainly positive. */ result->tv_sec = x->tv_sec - y->tv_sec; result->tv_usec = x->tv_usec - y->tv_usec; /* Return 1 if result is negative. */ return x->tv_sec < y->tv_sec; } -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com