# NFS with Finder very slow!



## morm (Jun 12, 2004)

has anybody an idea why NFS is so slow in OS X if you copy something with Finder ... and if u stick to the commandline it's ok 

i mounted nfs with the following parameters 

server:share /mnt  nfs -i,-w=8192,-s,-a=4,-3,-T,-b,-P,-g=32,nodev,-d,noatime,-r=8192,-I=8192 0 0

works fine 

but finder somehow "limits" the speed 

it is about 10x slower with finder if i copy something from the NFS server to the OS X box 

c.u. 

m.


----------



## Ripcord (Jun 12, 2004)

I never use NFS with OS X, but I do know that when you connect to drives in almost any way with Panther, it uses automount to map the volume.  The automounter is notoriously sucky (not just an OS X/BSD thing), and may not be setting very "ideal" mount options.

If you run "mount" after you've connected via the Finder, does it tell you what mount options it used when it connected?

If you're in a packet lossy environment, it makes a HUGE performance difference whether NFS mounts using TCP or UDP.  My guess is that automounter is using UDP by default, which would be way slower if stuff's getting dropped on your network for some reason (because of duplex mismatch or something silly like that)


----------



## morm (Jun 13, 2004)

i know ... i am using automounter of course 
but the actual thing is that it is very fast the nfs if i stick to the commanline when copying files ... *sorry* you might have misunderstood me 

what i actually mean is the following scenario: 

i mounted something from nfs on /mnt for example 
with the automounter. 

so when i try out the following 2 things i get some strange result: 

1) copy a file with finder from the nfs to my local drive 
2) copy a file with commandline cp  from the nfs to my local drive 

ad 1) it is very very slow  ... abut 600KByte/sec .. 
ad 2) it is very very fast ... about 9MByte/sec ... 


isn`t that wheired ... it seams that Finder does some strange things 
that make it slow ... actually it is not even heavily consuming cpu power
so i am very lost with this problem ... i do not unterstand the issue


----------



## Ripcord (Jun 13, 2004)

It looked more to me like you didn't use the automounter, but you instead used the "mount" command or threw something in the fstab.  Even if you ARE using the automounter, you're specifying a lot of mount options that OS X isn't necessarilly doing.

I'm still guessing the same things as before.  Do you see a lot of retransmissions on your two systems (both the OS X system and the NFS server): 

1) under the "tcp"->"x data packets retransmitted" section of "netstat -s" output  and/or 
2) under "Rpc Info"->"Retries" in "nfsstat" output?

If so, your problem is probably at least in some way related to packet drops.  And like I said, the OS X (FreeBSD) automounter may not be mounting using very "ideal" options for this kind of environment, wheras your manual mounting is a bit better for it.

...Or something similar to this.  I know people that use OS X + Finder + NFS and are able to get 9MB/s or more with Fast Ethernet, so I don't think it's JUST the Finder that's your issue here.


----------



## morm (Jun 13, 2004)

so u think that this cp command does some magic 
since it makes it possible to copy 9MB/sec ? 
this seams very strange to me %) 
i always thought that it should not matter which tool u use for copy


----------



## morm (Jun 13, 2004)

i looked at the netstats ... and they say there are no retransmits or errors
of course not  ... it works fine with cp 

here netstat 1 with 

1) Finder: 
            input        (Total)           output
   packets  errs      bytes    packets  errs      bytes colls

        45     0      65730         32     0       2890     0
        45     0      65730         32     0       2890     0
        45     0      65730         32     0       2890     0
        50     0      72820         32     0       3468     0
        45     0      65730         32     0       2890     0
stable like this  

2) cp command: 
            input        (Total)           output
   packets  errs      bytes    packets  errs      bytes colls
      6690     0    9463672       2176     0     278462     0
      6568     0    9320624       2144     0     273358     0
      5735     0    8123810       1856     0     238914     0
      6592     0    9329448       2144     0     273672     0
      5127     0    7265398       1664     0     213190     0
      6373     0    9068054       2112     0     266546     0
      5326     0    7568424       1728     0     221646     0
      6474     0    9163140       2112     0     269254     0
      6088     0    8642568       1984     0     254150     0
      6492     0    9218260       2112     0     269650     0

stable like this  

u see the difference? 
same mount 
same copy process of file 
different tool (cp vs. Finder) 

i am confused ... what does this Finder do?


----------



## Ripcord (Jun 13, 2004)

a


----------



## morm (Jun 14, 2004)

i had some thoughts about the problem 
one was that i still insist that i has to do with finder ... because if in the shell with cp it is fast it cannot be something with automounter and the other is actually that i have the feeling that maybe it is the symlink ... since if you mount something with automounter it is symlinked twice ... i will give a try on that ... but i seem to be to nerdy to do a sudo mount server:/home/shared /mnt
since this always returns me: 
 mount_nfs: /mnt: Permission denied
 whats up? ... i do not understand this 2 ... i mean ... isn`t it supposed to work like that?


----------



## morm (Jun 20, 2004)

i investigated quite a lot of time in finding out what the problem is 
and i am trying to tell you what i found out: 

I am using OpenBSD 3.5 as nfs-server and OS X latest version 10.3.4. 
Havin this problems especially with the finder i started ktracing the finder and cp. What i basically found out that the big difference between the copy process with the finder and cp is that finder uses pread(0xd,0x18eec00,0x3000,0,0x36000) 
and cp uses very traditional read(0x3,0x45b4,0x20000)

i really do not understand why they use pread since in my opinion read is the better approach since no explicit positioning inside the file is done.
but this did not satisfy my thirst of knowledge about this issue. So i also tried to find out how the buffer sizes are determined in both cases. cp seams to have a fixed buffersize, and finder somehow dynamically determines the buffersize (which is far to small). 
But anyhow, i did not want to believe that this is the problem alone, since you told me that it works  

so some further experiments. 
i tried out with a linux box if it is a problem of the OpenBSD nfs-server, and the result was that the OpenBSD nfs-server performs perfectly (10MB/sec read and 10MB/sec write!!!) 
so who is to blame?  
then i of course also tried nfs from OS X to linux, and it worked better than to OpenBSD, even with the finder (5MB/sec read at least) ... but still there is something wrong i guess because i tried NFS from OpenBSD to Linux and it was 10MB/sec read and 10MB/sec write. 
So there has to be something wrong with OS X. 

But still i did not give up and tried to optimize the NFS parameters in my use case OSX to OpenBSD. 
After trying out many combinations i came to a at least not too bad result 

with cp 10MB/sec read , 5MB/sec write 
with finder 4-5MB/sec read, 600KB/sec write 

so maybe there are some things i can still try out like timeouts on the ip layer and things like that... and i guess i will try these things out 

and finally here is how i mount now to get this result: 
server:share /mnt nfs -U,w=8388608,-P,-r=8388608

very funny actual is this 8388608Bytes read and writesize because usually one uses exactly 8 KBytes and anything larger with UDP does not make sense. but somehow 8 KBytes works fine as long as u don`t use the Finder. the Finder needs this big value because then it uses a bigger blocksize for copy operations which improves speed a lot. 

so i hope i could help now all people who do not have the problem *lol* 
it seams that i am the only one  

c.u. 
m.


----------



## xmltok (Jul 6, 2004)

i also have found this with nfs, unfortunately from what i have seen there is no way to fix this
i've read with linux it is nearly what it should be, with freebsd reads can be improved to a decent speed but writes are terribly slow. I eventually gave up with this and all i can recommend now is that you take a look at the netatalk 2.0 beta 2, it has afp3 (which supports long filenames) and works much faster than nfs, although it is still not as fast as an afp connection to another macosx machine.

it is not only finder that gives the slow results, it seems all macosx (not darwin) applications will read/write slow. itunes for example is much slower than finder


----------



## morm (Jul 6, 2004)

i really tried around a lot 
but it does not make any sense ... 
i mean i could start investigating into darwin kernel 
what goes wrong and so on 
but actually i will not do this for a company without being paid  

so i finally installed gnu debian linux ppc on my powerbook 
and you would not believe it 
nfs read and write is about 10 MBytes/sec 

so i switch back to linux until apple has fixed this problem 

YES I am a switcher has a new meaning for me now  

but thanx for replying since i really felt like i was the only one with this problem ... 

let's see maybe in Tiger they will fix it ... 

but anyway it only prooved what i always suspected 

commercial software suxx! 

its hard to admit but i am working in a software company 
and i have seen lots of software and was involved in lots of software 
and the final output of my experience is: 

you can be a genius but it does not help ... you will be forced by stupid 
management to build software that is crap at last 
because it will be more important to have a good time to market than quality 

they call it ... good enought quality ... i call it CRAP!!! 

thanx for listening  

m.


----------



## xmltok (Jul 7, 2004)

hey morm, have you considered running opendarwin on the pc? i would give it a try but i don't believe my 3ware raid card is supported
otherwise who knows! it could solve all of the problems and leave you with something nice on your powerbook


----------



## morm (Jul 8, 2004)

i tried it some time ago ... but hw support was too weak 
problems with scsii controller. .. . . 
now i have some new hw .... mybe it would work 
but setting up this computer takes lots of time 
since it has 3 nics (lan/wlan/internet) 
firewall ddns dhcp mailserver and things like that 
and i am really somehow convinced that OpenBSD is a good system 
for things like that ... it does not have too much anoying install scripts 
that do some config files and things like that. 
i like the idea of setting up everything by myself 
but i have some other hw ... maybe i should give a try on it 
i could even use linux then nfs would work (i tried this 2  ) ... 
but i stopped using linux for this server when i was too much annoyed by 
the linux is always changing symptom  
linux is a nice system but i do not like it when it has to do firewalling 
ipsec and things like that ... basically security things are far better in OpenBSD
but thanx for the suggestion ...  






			
				xmltok said:
			
		

> hey morm, have you considered running opendarwin on the pc? i would give it a try but i don't believe my 3ware raid card is supported
> otherwise who knows! it could solve all of the problems and leave you with something nice on your powerbook


----------



## xmltok (Jul 8, 2004)

it turned out my afp slowness was due to throttled (a bandwidth limiting app), it does not seem to handle the high bandwidth that well, with it disabled i get full 10mbit speeds with afp transfers
too bad i need an app like this since i can not get my cisco 806 router to do the job properly!


----------



## morm (Jul 8, 2004)

yes things like that might happen 
what is this deamon supposed to do anyway?


----------



## xmltok (Jul 8, 2004)

i use it to set a max on my bittorrent uploads so that it does not overload and slow down the downloading of other transfers
i've managed to get it to work without monitoring all the traffic so i can do my network mounts again properly

this is the app http://www.macupdate.com/info.php/id/7570


----------



## morm (Jul 8, 2004)

btw somehow i read somewhere that traffic shaping (limiting bandwidth and so on) works in darwin ... so there are even commandline, configs and so on .... i cannot tell you right now how ... because i got no mac online rite now (I am at work :/)  ... but it is already built into the system  
maybe this performs better


----------



## xmltok (Jul 8, 2004)

maybe you are talking about dummynet? it is not available in the darwin kernel, and by the looks of http://lists.apple.com/archives/darwinos-users/2001/Aug/09/dummynet.001.txt it might not ever be
and the search continues


----------



## morm (Jul 10, 2004)

about my nfs problem with finder

it is really "funny" 
i tried to copy 2 files at once 
and if there a 2 finder copy sessions 
nfs really performs ... it is then 9-10MB/sec at least 

now i am totally confused 
my guesses are there are some kernel tcp/ip (see sysctl) options messed up maybe or some dos attack whatever protection crap 
i will investigate on that 
since maybe i can play around with sysctl and fix the problem 

any ideas? 

m.


----------



## morm (Jul 10, 2004)

maybe apple thinks 5MB/sec are enough for 1 file


----------



## morm (Jul 10, 2004)

i read 
http://www.macosxhints.com/article.php?story=20040201121437157
the last post about smb/nfs 
and this keeps me on track searching for the issue to be solved 

this thread already sounds like a weblog 
any comments please!
i am really not that into tcp/ip 

m.


----------



## xmltok (Jul 10, 2004)

very interesting! i will get my nfs mounts going tonight and see what some tweaking reveals


----------



## xmltok (Jul 10, 2004)

it seems that none of those sysctl changes, nor the same but for udp make a difference for me
also i do not get the speed burst when doing two copies at once
however, with those sysctl changes, and a tcp mount, i am doing 1.6-1.7m/sec up from 700-800k/sec


----------



## morm (Jul 11, 2004)

yes and as i mentioned when you mount with 
-w=65536 // writebufsize
,-3             // NFS V3
,-U             // UDP  
,-P             // Priv Ports 
,-r=65536  // readbufsize 

you will get about 4MB/sec 

i will try TCP mount again with this sysctl options 
and try out different rsizes and wsizes 
maybe it improves then


----------

