Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
* Slow random file access under OSF/1 on Dec alpha
@ 1993-08-26 15:38 Brent McClure
  1993-08-27  0:36 ` Alan Rollow - Alan's Home for Wayward Tumbleweeds.
  1993-08-31 12:01 ` Jari Tavi
  0 siblings, 2 replies; 4+ messages in thread
From: Brent McClure @ 1993-08-26 15:38 UTC (permalink / raw)


I'm experiencing extremely slow file accesses when I have code that jumps
around in a file and accesses it at random locations.  The following 
sample program brings out the problem, and if the output file "foo" is
large enough ( greater than about 65536 bytes on our system ) then 
this program runs _much_ slower on our Dec Alpha than on any other
unix I can find to run it on.  

The interesting thing is if RECS and RECSIZE are tuned so that the size
of "foo" is around 2^16, then there is a dramatic change in the speed 
of this program as you cross this size boundary.

My guess is that there is some kernel parameter that I can tune to 
change this behavior, but I'm not sure what this would be.  Can anyone
suggest anything, or see if this occurs on your system?

Our osf version ( from uname -a ):
OSF1 jeremy 1.2 10 alpha

thanks, Brent
mcclure@cs.unm.edu

---------------------------------------------------------------------------
#include<stdio.h>
#include <fcntl.h>

/*
 * A combination of 13*5042 runs much slower on my alpha than 13*5041.
 */ 
#define RECSIZE 13
#define RECS 5042

char buf[128];
char nbuf[128];

main()
{
  int fd,i, val;

  /* make a couple of bogus buffers to write out */
  for( i = 0; i < RECSIZE; i++ ) {
    buf[i] = 'X';
    nbuf[i] = 'O'; 
  }

  fd = open("./foo",O_CREAT|O_RDWR,0644);

  /* unbuffer stdout so I can see how fast things are printing out */ 
  setbuf(stdout,NULL);

  printf("creating file...\n");
  for( i = 0; i < RECS; i++ ) {
    write(fd,buf,RECSIZE);
    if ( !(i%100) )
      printf("%d ",i);
  }
  printf("\n");

  printf("random access...\n");
  for( i = 0; i < RECS; i++ ) {
    val = rand()%RECS;
    lseek(fd,0,0);
    lseek(fd,val*RECSIZE,0);
    write(fd,nbuf,RECSIZE);
    if ( !(i%100) )
      printf("%d ",val*RECSIZE);
  }
  printf("\n");
}
---------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Slow random file access under OSF/1 on Dec alpha
  1993-08-26 15:38 Slow random file access under OSF/1 on Dec alpha Brent McClure
@ 1993-08-27  0:36 ` Alan Rollow - Alan's Home for Wayward Tumbleweeds.
  1993-08-31 12:01 ` Jari Tavi
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Rollow - Alan's Home for Wayward Tumbleweeds. @ 1993-08-27  0:36 UTC (permalink / raw)



In article <CCDI3H.400@tiguex.cs.unm.edu>, mcclure@tiguex.cs.unm.edu (Brent McClure) writes:
>Newsgroups: comp.unix.osf.misc
>From: mcclure@tiguex.cs.unm.edu (Brent McClure)
>Subject: Slow random file access under OSF/1 on Dec alpha
>
>I'm experiencing extremely slow file accesses when I have code that jumps
>around in a file and accesses it at random locations.  The following 
>sample program brings out the problem, and if the output file "foo" is
>large enough ( greater than about 65536 bytes on our system ) then 
>this program runs _much_ slower on our Dec Alpha than on any other
>unix I can find to run it on.  
>
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 customer 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 random I/Os cross this boundary the I/O
(I'd guess) the previous buffer is flushed.  From the I/O
speeds I'm seeing it may be that the current buffer won't
be "finished" until the previous one really is (*), but
I didn't look closely.  The behaviour may change slightly
by changing the value of delay_wbuffers.

It may also be that the I/O is being started asyncronously, but
as soon as the program tries to touch a buffer in transit, it
blocks waiting for the I/O to complete.  An interesting way to
test this might be to update the file backwards.

The reason that random (or backwards) is interesting, is that
the kernel knows (or thinks it knows) when access is sequential.
As long as you make too much of the buffer cache dirty, a program
writing sequentially, will run at the speed it takes to copy data
from the user buffer to the buffer cache.  Another interesting test
would be to see if the kernel things writing forward, but skipping
over the un-updated part is sequential:

+-------+-------+-------+-------+-------+
| write | skip	| write | skip	| write	|
+-------+-------+-------+-------+-------+

Other things we've learned about the problem is that it is specific
to UFS on OSF/1.  It doesn't occur on ULTRIX V4.3, nor does it
occur on OSF/1 using the POLYCENTER Advanced File System (or so
I've heard).

(*) Most file system I/O is done asynchronously.  To the user
a write appears complete when a buffer has been allocated
in the kernel and his data copied into that buffer.  It may be
some tens of seconds before the data is actually written to
disk.

>
>My guess is that there is some kernel parameter that I can tune to 
>change this behavior, but I'm not sure what this would be.  Can anyone
>suggest anything, or see if this occurs on your system?

On ULTRIX delay_wbuffers was in param.c, but it's moved to ufs_vnops.o
on OSF.  I wouldn't be surprised if the magick 64 KB number is also
around there somewhere instead of in param.c or a data file.

				* * *

Here is the program.  The arguments are:

	program file-name block-size io-size

I writes 2 "block-size" blocks and then goes through a loop seeking
back and forth between the two, write 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 <sys/types.h>
#include <sys/file.h>

#include <stdio.h>
#include <errno.h>

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) ;
}

--
Alan Rollow				alan@nabeth.cxo.dec.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Slow random file access under OSF/1 on Dec alpha
  1993-08-26 15:38 Slow random file access under OSF/1 on Dec alpha Brent McClure
  1993-08-27  0:36 ` Alan Rollow - Alan's Home for Wayward Tumbleweeds.
@ 1993-08-31 12:01 ` Jari Tavi
  1993-09-03 18:38   ` Tom McCabe
  1 sibling, 1 reply; 4+ messages in thread
From: Jari Tavi @ 1993-08-31 12:01 UTC (permalink / raw)



>My guess is that there is some kernel parameter that I can tune to 
>change this behavior, but I'm not sure what this would be.  Can anyone
>suggest anything, or see if this occurs on your system?

Alan said that this will/can be fixed, but until then there's also an
alternative: try using Advanced File System (AdvFS: shipping with V1.3).
Base functionality comes free with DEC OSF/1, and short tests with Alan's 
example shows very different behaviour from standard UFS. I tested this
with striping enabled and disabled and in both cases it was 'too fast'
in terms of Alan's program.

		-jari

--
-------------------------------------------------------------------------------
Full-Name:      Jari Tavi			
Organization:   DEC Finland                     Dept:           DS/OSG
Tel:            +358-0-434 5252	                Fax:            +358-0-452 1392 
E-mail:         jpt@rixrax.enet.dec.com
Address:        Digital Equipment Corporation Oy
                PL 16
                02201 Espoo
                FINLAND
-------------------------------------------------------------------------------
* All opinions are my personal, and do not necessarily represent opinions of
* my employer! 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Slow random file access under OSF/1 on Dec alpha
  1993-08-31 12:01 ` Jari Tavi
@ 1993-09-03 18:38   ` Tom McCabe
  0 siblings, 0 replies; 4+ messages in thread
From: Tom McCabe @ 1993-09-03 18:38 UTC (permalink / raw)


Jari Tavi (jpt@rixrax.enet.dec.com) wrote:


: Alan said that this will/can be fixed, but until then there's also an
: alternative: try using Advanced File System (AdvFS: shipping with V1.3).
: Base functionality comes free with DEC OSF/1, and short tests with Alan's
: example shows very different behaviour from standard UFS. I tested this
: with striping enabled and disabled and in both cases it was 'too fast'
: in terms of Alan's program.

: 		-jari

I will soon be switching from a DEC ultrix machine to a new alpha
workstation.  I would like to know a reasonable way to convert my ultrix
filesystems to osf filesystems. First will osf 1.3 recognize ultrix
filesystems?  If not, is there a product that comes with osf to 'easily'
convert scsi disks from ultrix to osf without losing everything?

From the note above it seems that when the osf machines arrive I will be
able to select one of several file system.  From others' experiences, does
the AdvFS system mentioned seem to be the best one?

thanks in advance
tom mccabe
tm@astros.cs.swt.edu

I should have mentioned that I am not getting any new disks....I will have
to convert all my disks over without benefit of new ones aid me!!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1993-09-03 18:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-08-26 15:38 Slow random file access under OSF/1 on Dec alpha Brent McClure
1993-08-27  0:36 ` Alan Rollow - Alan's Home for Wayward Tumbleweeds.
1993-08-31 12:01 ` Jari Tavi
1993-09-03 18:38   ` Tom McCabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox