mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Ashley <dash@xdr.com>
To: tadams-lists@myrealbox.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.4.18 beats 2.5.50 in hard drive access????
Date: Fri, 6 Dec 2002 21:51:52 -0800	[thread overview]
Message-ID: <200212070551.gB75pqj06406@dave.home> (raw)

hdparm -t yields similiar results on 2.4.18 and 2.5.50. What is a huge
difference is the scattered reads from a disk. At least it is good to
see other people experiencing similiar kernel messages. Would it help to
post the program? Here it is anyway:

Thanks--
Dave

//compile with
//gcc t.c -o t -lpthread

#include <stdio.h>
#include <stdlib.h>
#include <linux/fcntl.h>
#include <unistd.h>
#include <linux/unistd.h>
#include <sys/time.h>
#include <pthread.h>

char DEVNAME[128];
extern long long lseek64(int,long long,int);
unsigned char *tbuff;

long long now(void)
{
struct timeval tv;
	gettimeofday(&tv,0);
	return tv.tv_sec*1000000ll + tv.tv_usec;
}
int intcomp(const void *v1,const void *v2)
{
	return *(unsigned long *)v1 - *(unsigned long *)v2;
}
#define NUM 250
#define BLOCK (188*128*4ll)
int fd;
long long l;
char state[NUM];
void *readfunc(void *a)
{
long long off;
int lfd;
int r;
	lfd=open(DEVNAME,O_RDONLY|O_LARGEFILE|O_SYNC);
	off=(rand()&0x7fffffff)%l*BLOCK;
	lseek64(lfd,off,SEEK_SET);
	r=read(lfd,tbuff,BLOCK);
	state[(int)a]=1;
	close(lfd);
	return 0;
}


int main(int argc,char **argv)
{
long long lres;
int res;
int i,j;
long long start,off;
unsigned char *p;

if(argc<2) {printf("specify device to test\n");exit(0);}
strcpy(DEVNAME,argv[1]);
tbuff=malloc(BLOCK+4096);
fd=open(argv[1],O_RDONLY|O_LARGEFILE);
printf("fd=%d\n",fd);
if(fd<0) exit(0);
while((int)tbuff & 4095) ++tbuff; // align to PAGE_SIZE


l=lseek64(fd,0ll,SEEK_END);
printf("Total volume size=%lld megabytes\n",l/0x100000);
l/=BLOCK;
printf("%d blocks\n",l);
	start=now();
	srand((int)start);
	for(i=0;i<NUM;++i)
	{
		pthread_t tt;
		memset(&tt,0,sizeof(tt));
		pthread_create(&tt,0,readfunc,(void *)i);
	}
	for(;;)
	{
		for(i=0;i<NUM;++i)
			if(!state[i]) break;
		if(i==NUM) break;
		usleep(10000);
	}
	start=now()-start;
	printf("%f seconds\n",start/(float)1000000.0);
	printf("%f mbytes/second\n",(float)BLOCK*NUM/start);
	return 0;
}

             reply	other threads:[~2002-12-07  5:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-07  5:51 David Ashley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-12-07 17:19 David Ashley
2002-12-07 15:25 David Ashley
2002-12-07  3:02 Manish Lachwani
2002-12-07  2:48 David Ashley
2002-12-07  2:36 David Ashley
2002-12-06 23:02 Manish Lachwani
2002-12-06 23:00 David Ashley
2002-12-07  2:10 ` Alan Cox
2002-12-07  4:29   ` Trever L. Adams
2002-12-08  1:55     ` Alan Cox
2002-12-08  3:28       ` Tomas Szepe
2002-12-08 17:27       ` Trever L. Adams
2002-12-06 19:29 David Ashley
2002-12-06 23:20 ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200212070551.gB75pqj06406@dave.home \
    --to=dash@xdr.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tadams-lists@myrealbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®