Awful NFS performance with attached test program

From: jlnance
Date: Mon Jan 19 2004 - 16:19:44 EST


Hello All,
The attached program demonstrates a problem I am having writing to
files on an NFS file system. It works by creating a file, and then
seeking through the file to update it. The problem I am seeing is that
the seek/update stage takes more than 10X as long as the amount of time
required to initially create the file. And its not even seeking in
some strange pattern.

I am running this with a 2.4.20 (red hat patched) kernel. I have not
tried it with 2.6. I have played with various mount options, but they
do not seem to make much difference. Here is one example that I used:

sledge:/l0 /mnt/v3_tcp_8k nfs rw,v3,rsize=8192,wsize=8192,hard,intr,tcp,lock,addr=sledge 0 0

Anyone have any ideas or comments?

Thanks,

Jim


----------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>

char buff[4096];

double dt(struct timeval *a, struct timeval *b)
{
double sec = b->tv_usec - a->tv_usec;

sec /= 1e6;
sec += b->tv_sec - a->tv_sec;

return sec;
}

int main()
{
struct timeval a, b;
int i;

FILE *fp = fopen("testfile", "w");

printf("Creating file: ");
fflush(stdout);
gettimeofday(&a, 0);
for(i=0; i<100*1024; i++)
fwrite(buff, 4096, 1, fp);
fflush(fp);
gettimeofday(&b, 0);

printf("%.3f seconds\n", dt(&a, &b));

printf("Updating file: ");
fflush(stdout);
gettimeofday(&a, 0);
for(i=0; i<100*1024*sizeof(buff); i += 5000) {
fseek(fp, i, SEEK_SET);
fwrite(&i, sizeof(i), 1, fp);
}
gettimeofday(&b, 0);

printf("%.3f seconds\n", dt(&a, &b));

return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/