I have explained why Java is so slow to do this operation.  It's not
really "Java's implementation of the NFS" but actually a side effect
of how the File class works.   I assume in C, when you get a directory
list, all the information comes back in one hit.  And you can get all
the attributes you want right away.  When Java gets a directory list
it probably does the same thing - but then it does something
different. It pulls out the names (and only the names) and creates a
list of File objects, puts them in an array and passes them back to
you.  Remember, all the File object really has inside it is the path
to the file.  Any call to say isDirectory() forces it to go back to
the OS with the full path to the file and ask for the attribute, and
thus calling back to the remote server.

On Jan 7, 4:29 pm, John Muir <[email protected]> wrote:
> Hi Paul,
>
> I've seen the Javadoc for the new NIO somewhere but could not
> immediately find any references to better performance or network
> latency. I think there was a new Method (getAttributes() or something
> similar). Do we have to use different methods to get the faster
> performance or should the program be unchanged? Anyone know?
>
> I'll try the beta out and report back...
>
> @Christian
>
> "A network file system will have the "standard" problem of round trip
> latency time for any operations which can not be aggregated into one
> call."
>
> So how come the C program is so fast? The problem must surely lie in
> the Java implementation of the NFS.
>
> Thanks all, John
>
> On Jan 7, 3:37 am, Paul King <[email protected]> wrote:
>
>
>
> > JSR-203 is already incorporated in the beta builds at
> > jdk7.dev.java.net including JavaDoc and Sun tutorials.
> > I don't know if it fixes any of your performance issues but would be
> > interested in your experiences if you try it.
>
> > Cheers, Paul.
>
> > On Thu, Jan 7, 2010 at 9:48 AM, John Muir <[email protected]> wrote:
> > > And does anyone know when JSR-203 will be implemented? Java 7?
>
> > > On Jan 7, 12:46 am, John Muir <[email protected]> wrote:
> > >> I think you are on to the correct explanation, at least from what I
> > >> read on the Sun/Bugs site. It seems to be related to caching the file
> > >> information.
>
> > >> However, as the facts stand it's much slower over the network, so to
> > >> return to the original post - does anyone have a solution or
> > >> workaround?
>
> > >> On Jan 7, 12:09 am, Christian Catchpole <[email protected]>
> > >> wrote:
>
> > >> > Here is my "guess" as to what is happening (I had a quick look at the
> > >> > bug ticket but couldn't see an explanation).
>
> > >> > And I haven't written this sort of code in C for a while, so this is
> > >> > an extra big guess.
>
> > >> > When you get a dir list in Java it creates a list of File objects
> > >> > which are just paths to the file.  Calling isDirectory() forces is to
> > >> > go back the the network because it doesn't have any kind of real
> > >> > handle on the OS object which represents the file.
>
> > >> > In C, when you get a directory list, do you get a list of "handles to
> > >> > OS objects" which can be polled immediately for an attribute?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "The Java Posse" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to 
> > > [email protected].
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/javaposse?hl=en.
-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.


Reply via email to