🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
6 messages
6 total messages Started by Tim Thompson Mon, 24 Jun 1996 00:00
NFS V3 problem with readdir(3C)
#8734
Author: Tim Thompson
Date: Mon, 24 Jun 1996 00:00
87 lines
3395 bytes
  I've got a cluster of Sun Sparc 10's and 20's, all running Solaris 2.5.1
  (NOT 2.5). Via a private NFS network (10Base-T), /var/spool/news is shared
  amongst them. We're using NFS to separate "feeding" functionality from
  "reading" functionality. It works well for us; well, it works well for
  us provided we don't use NFS V3.

  Part of the reason we went to Solaris 2.5 (and then 2.5.1 due to a bug
  in 2.5 where some sort of inode cache would exhaust all kernel memory)
  was because it was rumored that NFS V3 would provide us with much 
  better performance than V2. However, it appears that readdir(3C) is
  *much* slower in a V3 environment than in V2.
  
  On our test machine, I've put the following entries in /etc/vfstab:

	machine:/var/spool/news   -    /V2  nfs  -    yes  vers=2
	machine:/var/spool/news   -    /V3  nfs  -    yes  vers=3

  I've created the directories /V2 and /V3, and then mounted the file
  systems:

  $ mount | grep V

  /V2 on machine:/var/spool/news vers=2/remote on Mon Jun 24 13:28:04 1996
  /V3 on machine:/var/spool/news vers=3/remote on Mon Jun 24 13:28:06 1996

  Then I run this short test program (included below). Notice the time to 
  look at things on the file system mounted using NFS Version 2 is *much*
  less than the time on the file system mounted using NFS version 3.

	$ ./testprog /V2/alt/test
	START TIME: Mon Jun 24 15:20:58 1996
	 
	END TIME: Mon Jun 24 15:21:00 1996
	 
	$ ./testprog /V3/alt/test
	START TIME: Mon Jun 24 15:21:04 1996
	 
	END TIME: Mon Jun 24 15:27:30 1996
	 
  Granted, I've only shown a sample of one here, but the results are 
  consistent: the time to run on the V3 file system is always considerable
  more than on the V2 file system.

  It looks like the readdir(3C) system call is taking an inordinate amount
  of time when NFS V3 is being used.

  Any/all suggestions are most welcome.

					Tim Thompson
					tgt@lucent.com

P.S. I've got a call into Sun support on this problem.

========================> cut here <=======================
#include <dirent.h>
 
main(argc,argv)
int argc;
char *argv[];
{
    register struct dirent      *ep;
    register DIR        *dp;
    long now;
 
    dp = opendir(argv[1]);
 
    if (dp == NULL) {
        printf("No such directory!\n");
        exit(-1);
    }
 
    now = time(0);
    printf("START TIME: %s\n", ctime(&now));
    while ((ep = readdir(dp)) != NULL)
        ;
 
    now = time(0);
    printf("END TIME: %s\n", ctime(&now));
}
-- 
This is an all-natural posting, containing | Tim Thompson
no artificial colorings, flavorings, or    | Netnews Service Manager/Engineer
preservatives.                             | Lucent Technologies
                                           | tgt@lucent.com

Re: NFS V3 problem with readdir(3C)
#8762
Author: Michael R. Eisler
Date: Mon, 24 Jun 1996 00:00
99 lines
3997 bytes
In article <4qmr2b$64s@nntpa.cb.lucent.com>,
Tim Thompson <tgt@pongo.cb.att.com> wrote:
>  I've got a cluster of Sun Sparc 10's and 20's, all running Solaris 2.5.1
>  (NOT 2.5). Via a private NFS network (10Base-T), /var/spool/news is shared
>  amongst them. We're using NFS to separate "feeding" functionality from
>  "reading" functionality. It works well for us; well, it works well for
>  us provided we don't use NFS V3.
>
>  Part of the reason we went to Solaris 2.5 (and then 2.5.1 due to a bug
>  in 2.5 where some sort of inode cache would exhaust all kernel memory)
>  was because it was rumored that NFS V3 would provide us with much 
>  better performance than V2. However, it appears that readdir(3C) is
>  *much* slower in a V3 environment than in V2.
>  
>  On our test machine, I've put the following entries in /etc/vfstab:
>
>	machine:/var/spool/news   -    /V2  nfs  -    yes  vers=2
>	machine:/var/spool/news   -    /V3  nfs  -    yes  vers=3
>
>  I've created the directories /V2 and /V3, and then mounted the file
>  systems:
>
>  $ mount | grep V
>
>  /V2 on machine:/var/spool/news vers=2/remote on Mon Jun 24 13:28:04 1996
>  /V3 on machine:/var/spool/news vers=3/remote on Mon Jun 24 13:28:06 1996
>
>  Then I run this short test program (included below). Notice the time to 
>  look at things on the file system mounted using NFS Version 2 is *much*
>  less than the time on the file system mounted using NFS version 3.
>
>	$ ./testprog /V2/alt/test
>	START TIME: Mon Jun 24 15:20:58 1996
>	 
>	END TIME: Mon Jun 24 15:21:00 1996
>	 
>	$ ./testprog /V3/alt/test
>	START TIME: Mon Jun 24 15:21:04 1996
>	 
>	END TIME: Mon Jun 24 15:27:30 1996
>	 
>  Granted, I've only shown a sample of one here, but the results are 
>  consistent: the time to run on the V3 file system is always considerable
>  more than on the V2 file system.
>
>  It looks like the readdir(3C) system call is taking an inordinate amount
>  of time when NFS V3 is being used.
>
>  Any/all suggestions are most welcome.

Solaris 2.5 clients use the NFS3_READDIRPLUS procedure which will also return
attributes withe each directory entry. Programs like find, ls -l,
etc. are supposed to be faster. It would be itneresting to seehow your
test program performans if you stat() each entry in the directory.
>
>					Tim Thompson
>					tgt@lucent.com
>
>P.S. I've got a call into Sun support on this problem.
>
>========================> cut here <=======================
>#include <dirent.h>
> 
>main(argc,argv)
>int argc;
>char *argv[];
>{
>    register struct dirent      *ep;
>    register DIR        *dp;
>    long now;
> 
>    dp = opendir(argv[1]);
> 
>    if (dp == NULL) {
>        printf("No such directory!\n");
>        exit(-1);
>    }
> 
>    now = time(0);
>    printf("START TIME: %s\n", ctime(&now));
>    while ((ep = readdir(dp)) != NULL)
>        ;
> 
>    now = time(0);
>    printf("END TIME: %s\n", ctime(&now));
>}
>-- 
>This is an all-natural posting, containing | Tim Thompson
>no artificial colorings, flavorings, or    | Netnews Service Manager/Engineer
>preservatives.                             | Lucent Technologies
>                                           | tgt@lucent.com


-- 
-Mike Eisler			NFS group
mre@Eng.Sun.Com			SunSoft

Re: NFS V3 problem with readdir(3C)
#8770
Author: Tim Thompson
Date: Tue, 25 Jun 1996 00:00
85 lines
3223 bytes
In article <4qn5r9$3hb@engnews2.eng.sun.com>,
Michael R. Eisler <mre@eng.sun.com> wrote:
>
>Solaris 2.5 clients use the NFS3_READDIRPLUS procedure which will also return
>attributes withe each directory entry. Programs like find, ls -l,
>etc. are supposed to be faster. It would be itneresting to seehow your
>test program performans if you stat() each entry in the directory.

I just did this, and still got similar results (program included below).
Just to be fair, I've got two versions of the program, one with stat(), and
one without it. I've used the one that includes stat() on the V2-mounted
file system, and the one without on the V3 file system. Since NFS3_READDIRPLUS
is used in NFS V3, there's no point in doing the extra stat(). Observe
the results:

	$ ./with_stat /V2/alt/test
	START TIME: Tue Jun 25 09:27:05 1996
	 
	END TIME: Tue Jun 25 09:27:09 1996
	  
	$ ./without_stat /V3/alt/test
	START TIME: Tue Jun 25 09:27:21 1996
	   
	END TIME: Tue Jun 25 09:33:28 1996
    

Another interesting point is if I run the program on the V3-mounted file
system immediately after the first run, performance is acceptable - it must
have the file attributes cached on the client:

	$ ./without_stat /V3/alt/test
	START TIME: Tue Jun 25 09:36:32 1996
	 
	END TIME: Tue Jun 25 09:36:33 1996


Is there any way to turn off READDIRPLUS for a V3-mounted file system?

					Tim Thompson
					tgt@lucent.com

FILE: with_stat.c
==================================================================
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
 
main(argc,argv)
int argc;
char *argv[];
{
    register struct dirent      *ep;
    register DIR        *dp;
    long now;
    register struct stat        *statbuf;
 
    dp = opendir(argv[1]);
 
    if (dp == NULL)
    {
        printf("No such directory!\n");
        exit(-1);
    }
 
 
    now = time(0);
    printf("START TIME: %s\n", ctime(&now));
    while ((ep = readdir(dp)) != NULL)
        stat(ep->d_name, statbuf);
 
    now = time(0);
    printf("END TIME: %s\n", ctime(&now));
}
==================================================================

The file without_stat.c is exactly the same, except the stat() line
is replaced by a single semi-colon.
-- 
This is an all-natural posting, containing | Tim Thompson
no artificial colorings, flavorings, or    | Netnews Service Manager/Engineer
preservatives.                             | Lucent Technologies
                                           | tgt@lucent.com

Re: NFS V3 problem with readdir(3C)
#8780
Author: Michael R. Eisler
Date: Tue, 25 Jun 1996 00:00
121 lines
4339 bytes
In article <4qoq8q$9f0@nntpa.cb.lucent.com>,
Tim Thompson <tgt@pongo.cb.att.com> wrote:
>In article <4qn5r9$3hb@engnews2.eng.sun.com>,
>Michael R. Eisler <mre@eng.sun.com> wrote:
>>
>>Solaris 2.5 clients use the NFS3_READDIRPLUS procedure which will also return
>>attributes withe each directory entry. Programs like find, ls -l,
>>etc. are supposed to be faster. It would be itneresting to seehow your
>>test program performans if you stat() each entry in the directory.
>
>I just did this, and still got similar results (program included below).

Your new  program has a flaw, unless your current working directory is
equal to  the directory your are opening. The stat()'s will all return
errors as you've currently written your program. You need a chdir(argv[1])
before you start readding and stating your dir entries.

>Just to be fair, I've got two versions of the program, one with stat(), and
>one without it. I've used the one that includes stat() on the V2-mounted
>file system, and the one without on the V3 file system. Since NFS3_READDIRPLUS
>is used in NFS V3, there's no point in doing the extra stat(). Observe

But then you are being unfair to NFS V2.

>the results:
>
>	$ ./with_stat /V2/alt/test
>	START TIME: Tue Jun 25 09:27:05 1996
>	 
>	END TIME: Tue Jun 25 09:27:09 1996
>	  
>	$ ./without_stat /V3/alt/test
>	START TIME: Tue Jun 25 09:27:21 1996
>	   
>	END TIME: Tue Jun 25 09:33:28 1996

I'm not seeing these results. I created a directory with 1002 entries.

without stat:

% /tmp/a.out /tmp/mre/V3/tmp/test
START TIME: Tue Jun 25 10:04:46 1996
 
END TIME: Tue Jun 25 10:04:48 1996
 
COUNT: 1002

% /tmp/a.out /tmp/mre/V2/tmp/test
START TIME: Tue Jun 25 10:05:12 1996
 
END TIME: Tue Jun 25 10:05:12 1996
 
COUNT: 1002

with stat:

% /tmp/a.out /tmp/mre/V2/tmp/test with_stat
START TIME: Tue Jun 25 10:17:00 1996
 
END TIME: Tue Jun 25 10:17:11 1996
 
COUNT: 1002
% /tmp/a.out /tmp/mre/V3/tmp/test with_stat
START TIME: Tue Jun 25 10:17:26 1996
 
END TIME: Tue Jun 25 10:17:28 1996
 
COUNT: 1002

Between runs of without stat and with stat, I mounted a different
hostname of my multihomed server so tht directory and rnode caches would
be missed with 2nd run. I should have also created two separate
directories on my server so that server caching didn't come into
play. Finally I didn't run this on a private net. Nonethless, I'm not
seeing the disparity in version 2 and Version 3 performance you are.

How big is your test direcotory and how long are the names?

>Another interesting point is if I run the program on the V3-mounted file
>system immediately after the first run, performance is acceptable - it must
>have the file attributes cached on the client:

Attributes and directories are cached.

>
>	$ ./without_stat /V3/alt/test
>	START TIME: Tue Jun 25 09:36:32 1996
>	 
>	END TIME: Tue Jun 25 09:36:33 1996
>
>
>Is there any way to turn off READDIRPLUS for a V3-mounted file system?

I haven't looked, but I think there is something else going on here that
should be investigated.

>    register struct stat        *statbuf;

	statbuf has to initialized to point to something.
> 
>    dp = opendir(argv[1]);
> 
>    if (dp == NULL)
>    {
>        printf("No such directory!\n");
>        exit(-1);
>    }
> 
> 
>    now = time(0);
>    printf("START TIME: %s\n", ctime(&now));
>    while ((ep = readdir(dp)) != NULL)
>        stat(ep->d_name, statbuf);

if argv[1] is not equal to ".", then the stat() will fail.
-- 
-Mike Eisler			NFS group
mre@Eng.Sun.Com			SunSoft

Re: NFS V3 problem with readdir(3C)
#8789
Author: Ray W. Hiltbrand
Date: Tue, 25 Jun 1996 00:00
124 lines
5543 bytes
Also a question on your runs?  After you run your test
program the first time do you see a speed increase for 
v3 compared to the first run?  A USENIX paper[PAW94] I just read 
talked about the use of the READDIRPLUS function of NFS v3.
One of the pitfall it noted was that after the first readdirplus
call most info should then be in the clients cache so a readdir
would be more efficient. 

Michael is the readdir system call setup to take advantage of
a client side cache such that it would not slow down access
once the first readdirplus was made to the server?


[PAW94] Brian Pawlowski, Chet Juszczak, Peter Staubach, Carl Smith,
Diane Lebel, and David Hitz."NFS Version 3 Design and Implementation"
In USENIX Summer 1994 Technical Conference, page 137-152, June 1994


Michael R. Eisler wrote:
> 
> In article <4qmr2b$64s@nntpa.cb.lucent.com>,
> Tim Thompson <tgt@pongo.cb.att.com> wrote:
> >  I've got a cluster of Sun Sparc 10's and 20's, all running Solaris 2.5.1
> >  (NOT 2.5). Via a private NFS network (10Base-T), /var/spool/news is shared
> >  amongst them. We're using NFS to separate "feeding" functionality from
> >  "reading" functionality. It works well for us; well, it works well for
> >  us provided we don't use NFS V3.
> >
> >  Part of the reason we went to Solaris 2.5 (and then 2.5.1 due to a bug
> >  in 2.5 where some sort of inode cache would exhaust all kernel memory)
> >  was because it was rumored that NFS V3 would provide us with much
> >  better performance than V2. However, it appears that readdir(3C) is
> >  *much* slower in a V3 environment than in V2.
> >
> >  On our test machine, I've put the following entries in /etc/vfstab:
> >
> >       machine:/var/spool/news   -    /V2  nfs  -    yes  vers=2
> >       machine:/var/spool/news   -    /V3  nfs  -    yes  vers=3
> >
> >  I've created the directories /V2 and /V3, and then mounted the file
> >  systems:
> >
> >  $ mount | grep V
> >
> >  /V2 on machine:/var/spool/news vers=2/remote on Mon Jun 24 13:28:04 1996
> >  /V3 on machine:/var/spool/news vers=3/remote on Mon Jun 24 13:28:06 1996
> >
> >  Then I run this short test program (included below). Notice the time to
> >  look at things on the file system mounted using NFS Version 2 is *much*
> >  less than the time on the file system mounted using NFS version 3.
> >
> >       $ ./testprog /V2/alt/test
> >       START TIME: Mon Jun 24 15:20:58 1996
> >
> >       END TIME: Mon Jun 24 15:21:00 1996
> >
> >       $ ./testprog /V3/alt/test
> >       START TIME: Mon Jun 24 15:21:04 1996
> >
> >       END TIME: Mon Jun 24 15:27:30 1996
> >
> >  Granted, I've only shown a sample of one here, but the results are
> >  consistent: the time to run on the V3 file system is always considerable
> >  more than on the V2 file system.
> >
> >  It looks like the readdir(3C) system call is taking an inordinate amount
> >  of time when NFS V3 is being used.
> >
> >  Any/all suggestions are most welcome.
> 
> Solaris 2.5 clients use the NFS3_READDIRPLUS procedure which will also return
> attributes withe each directory entry. Programs like find, ls -l,
> etc. are supposed to be faster. It would be itneresting to seehow your
> test program performans if you stat() each entry in the directory.
> >
> >                                       Tim Thompson
> >                                       tgt@lucent.com
> >
> >P.S. I've got a call into Sun support on this problem.
> >
> >========================> cut here <=======================
> >#include <dirent.h>
> >
> >main(argc,argv)
> >int argc;
> >char *argv[];
> >{
> >    register struct dirent      *ep;
> >    register DIR        *dp;
> >    long now;
> >
> >    dp = opendir(argv[1]);
> >
> >    if (dp == NULL) {
> >        printf("No such directory!\n");
> >        exit(-1);
> >    }
> >
> >    now = time(0);
> >    printf("START TIME: %s\n", ctime(&now));
> >    while ((ep = readdir(dp)) != NULL)
> >        ;
> >
> >    now = time(0);
> >    printf("END TIME: %s\n", ctime(&now));
> >}
> >--
> >This is an all-natural posting, containing | Tim Thompson
> >no artificial colorings, flavorings, or    | Netnews Service Manager/Engineer
> >preservatives.                             | Lucent Technologies
> >                                           | tgt@lucent.com
> 
> --
> -Mike Eisler                    NFS group
> mre@Eng.Sun.Com                 SunSoft

--
Ray W. Hiltbrand                Ray.W.Hiltbrand@eng.auburn.edu
Engineering Network Services
Auburn University     http://www.eng.auburn.edu/~rayh/rayh.html
   If it doesn't do what you want, subclass and override.

Re: NFS V3 problem with readdir(3C)
#8798
Author: Quentin Fennessy
Date: Tue, 25 Jun 1996 00:00
10 lines
912 bytes
Tim-
	I am curious to see the output of nfsstat -c both before and after
	your test runs.  Perhaps that can tell where the time was spent.


-- 
Quentin Fennessy			AMD, Austin Texas

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads