From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,a247b9f21a6d13d6 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-08-27 14:50:57 PST Newsgroups: comp.sys.dec Path: gmd.de!xlink.net!sol.ctr.columbia.edu!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!decwrl!pa.dec.com!nntpd2.cxo.dec.com!nabeth.cxo.dec.com!alan From: alan@nabeth.cxo.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.) Subject: Re: Our DEC Alpha is the slowest on this code .... Message-ID: <1993Aug27.214032.10670@nntpd2.cxo.dec.com> Sender: usenet@nntpd2.cxo.dec.com (USENET News System) Reply-To: alan@nabeth.cxo.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.) Organization: Digital Equipment Corporation References: <25juna$n5e@polaris.unm.edu> Distribution: usa Date: Fri, 27 Aug 1993 21:40:32 GMT In article <25juna$n5e@polaris.unm.edu>, espen@unm.edu (Peter Espen) writes: >Our company ports code to a lot of different unix systems. We have in the >lab: > > [ List deleted. ] >We have come across some sort of weakness on the Dec Alpha that causes >a real slowdown in execution speed. Even the Apple Quadra 900 running A/UX >runs rings around the Alpha on the following little test program. Anyone >know why? [ This is an updated version of a follow-up to a version of the original question that was posted to comp.sys.osf.misc. ] Using a similar program that let me adjust a "block" size and the I/O size, I was able to do some experimentation. The program is below. The problem had been noticed by some other customers using FORTRAN and it has been reported internally. The problem is still present in V1.3, so the earliest it would be fixed without a patch is the next version after V1.3. >From my experiments, it appears there is a special boundary every 64 KB. When I/Os cross this boundary either the current or previous buffer is written asynchronously. As long as a buffer is in transit, further attempts to update it are blocked until the I/O is complete. In the cases of the original program and mine a small number of buffers are being updated more quickly than their writes can complete, so the program is I/O bound. The behaviour can be changed somewhat by changing the value of delay_wbuffers. When set it causes writes that would ordinarily be started right away to be delayed until flushed with a sync (sync(2) or fsync(2)). The advantage for this sort of application is that it allows more write-merging. The disadvantage is that it applies to all file systems and allows more data to become stale. If the system is unstable for any reason, this stale data will be lost in a crash. Another potential solution to this problem (depending on the system) is Prestoserve. I believe it will also cache some asynchronous writes as well as synchronous ones. While this won't merge all the writes, it will help some of them. If the file system that is the target of this sort of I/O can be isolated, it may worthwhile to mount the file system for synchronous writes (or open the file for synchronous writes). With Prestoserve enabled, all the synchronous writes will benefit from the cache. Other follow-ups in the string mentioned ULTRIX having a similar problem. In that case, the condition that caused delay_wbuffers to be examined was when a transfer ended on a file system block boundary. Clearly the OSF condition seems to be different. * * * Here is the program. The arguments are: program file-name block-size io-size It writes 2 "block-size" blocks and then goes through a loop seeking back and forth between the two, writing an "io-size" buffer after each lseek. When the I/O stays within one 64 KB area, the program makes the area dirty, but little I/O occurs. For example: program data 32768 8192 runs very fast, but: program data 65536 8192 doesn't. /* * Author: Alan Rollow, Subsystems Engineering, Digital Equipment Corp. * File: %M% * Date: %G% * Version: %I% * * %M% - Exercise the magic 64 KB boundary. */ #ifndef lint static char SccsId[] = "%W% %G%" ; #endif #include #include #include #include char *program ; main(argc, argv) int argc ; char *argv[] ; { char *file ; register fd, size, iosize ; if( argc < 4 ) { fprintf(stderr, "usage: %s file size iosize\n", argv[0]) ; exit(-1) ; } else { program = argv[0] ; file = argv[1] ; size = atoi(argv[2]) ; iosize = atoi(argv[3]) ; } if((fd = open(file, O_WRONLY|O_CREAT, 0644)) == -1 ) { fprintf(stderr, "%s: Can't open %s: %s.\n", program, file, strerror(errno)) ; exit(errno) ; } write_file(fd, file, size) ; exercise_file(fd, file, size, iosize) ; if( close(fd) == -1 ) fprintf(stderr, "%s: Can't close %s: %s.\n", program, file, strerror(errno)) ; return 0 ; } #define NBLOCKS (2) /* * Write NBLOCKS blocks of "size" in the file. */ write_file(fd, file, size) int fd, size ; char *file ; { char *buffer ; void *malloc() ; int rc ; if((buffer = (char *)malloc(size * NBLOCKS)) == NULL ) { fprintf(stderr, "%s: Can't allocate %d bytes: %s.\n", program, size * NBLOCKS, strerror(errno)) ; exit(errno) ; } if((rc = write(fd, buffer, size * NBLOCKS)) == -1 ) { fprintf(stderr, "%s: Write error on %s: %s.\n", program, file, strerror(errno)) ; exit(errno) ; } else if( rc != (size * NBLOCKS)) { fprintf(stderr, "%s: Short write of %d bytes on %s.\n", program, rc, file) ; exit(-1) ; } else free((void *)buffer) ; return ; } #define ALOT 1000 /* * The file consists of two block of "size" bytes each. Seeking * between block, write "iosize" bytes. Do this "ALOT" of times * and measure the time as simply as possible. */ exercise_file(fd, file, size, iosize) register fd ; int size ; char *file ; register iosize ; { time_t before, after, time() ; register loops, rc ; register char *buffer ; register size_t total ; if((buffer = (char *)malloc(iosize)) == NULL ) { fprintf(stderr, "%s: Can't allocate %d bytes: %s.\n", program, iosize, strerror(errno)) ; exit(errno) ; } loops = ALOT ; total = 0L ; before = time((time_t)0) ; /* * Seek to the beginning of the first "size" block and write * something, then seek to the beginning 2nd "size" block * and write something. * * It appears, that when the I/Os spans a 64 KB boundary * the previous buffer is flushed. The guess of the author * is that the I/O is started to complete asynchronously. * * If the I/O stays within one of these 64 KB boundaries, * very little I/O occurs. */ while( loops-- ) { if( lseek(fd, 0L, SEEK_SET) == -1 ) fprintf(stderr, "%s: Rewind failed on %s: %s.\n", program, file, strerror(errno)) ; if((rc = write(fd, buffer, iosize)) == -1 ) fprintf(stderr, "%s: First write failed on %s: %s.\n", program, file, strerror(errno)) ; else total += rc ; if( lseek(fd, (off_t)size, SEEK_SET) == -1 ) fprintf(stderr, "%s: Seek failed on %s: %s.\n", program, file, strerror(errno)) ; if((rc = write(fd, buffer, iosize)) == -1 ) fprintf(stderr, "%s: Second write failed on %s: %s.\n", program, file, strerror(errno)) ; else total += rc ; } after = time((time_t)0) ; free((void *)buffer) ; if( after - before ) { printf("%d I/Os in %d seconds: %f tps, %f KB/sec.\n", ALOT * 2, after - before, (double)(ALOT * 2)/(after - before), (double)(total / 1024)/(after - before)) ; } else printf("%d I/Os and %d KB too fast.\n", ALOT * 2, total / 1024) ; } > > [ The customer's program deleted. ] >Thanks! > >Peter Espen >espen@polaris.unm.edu > -- Alan Rollow alan@nabeth.cxo.dec.com