Subject: Re: Kernel copyin/out optimizations for ARM...
To: John Clark <j1clark@ucsd.edu>
From: John Clark <j1clark@ucsd.edu>
List: port-arm
Date: 03/11/2002 22:40:49
Well, I hit send before I put in some data and program examples.

At the moment I have a source and sink program set, which
on the XScale processor gives me a Number, .047 'seconds
per OS read call from a pipe (sources to follow). The same
program when run on my aging AMD K6 233 Mhz processor
under FreeBSD runs at about .000100 seconds per write... about 400
times faster... Similarly so does my AMD based Presario laptop running
NetBSD.

The last example of the below programs is just a write to /dev/null to
see what the 'system entry' overhead may be.

------ example test programs -------

command line:

# ./src 1000 | ./sink

------ src.c ------

#include <stdio.h>

char buf[0x100000];

main( int argc, char **argv )
{
         int count, i;

         if( argc > 1 ) sscanf( *++argv, "%d", &count );
         else count = 100;

         for( i = 0; i < count; i++ )
                 write( 1, buf, sizeof(buf) );

         close(1);
}


----- sink.c -------
#include <stdio.h>
#include <time.h>

char buf[0x100000];

main()
{
         int l, b;
         int count;
         time_t start = time(NULL);

         for( count = 1, b = 0;  l = read(0, buf, sizeof( buf ) ); 
count++, b += l )
                 ;

         printf( "bytes %d count %d time %10.6lf\n", b, count,
                 (double)((time(NULL) - start))/((double)count) );
}

----- tnull.c ------
#include <stdio.h>
#include <fcntl.h>
#include <time.h>

char buf[0x100000];

main( int argc, char **argv )
{
         time_t start;

         int fd;
         int count;
         int i;

         if ( argc > 1 ) sscanf( *++(argv), "%d", &count );
         else count = 100;

         fd = open( "/dev/null", O_RDWR );

         start = time( NULL );
         for( i = 0; i < count; i++ ) write( fd, buf, sizeof(buf) );

         printf( "time %10.6lf\n", (double)((time(NULL) - 
start))/((double)count) );
}