Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Speed up Samba file copying speeds Network
I've had absolutely horrible speeds while copying files from my Samba server, and it was starting to drive me nuts. Well, for those of you that experience this, there is a very easy fix. Simply add the following line to /etc/sysctl.conf (this is the file that is read on boot to set sysctl variables):
net.inet.tcp.delayed_ack=0
This simply tells the TCP stack in the kernel to not delay packet acks. The reason the slow down occurs is that when you are not sending anything to the Samba server, but attempting to copy a huge file from it, your computer will queue up a bunch of acks, and then send them after a bit. This causes the Samba server to stop sending files as fast, and then you end up going only a few kilobytes per second.

If you want instant gratification, open up a terminal window and sudo su -. Then, paste this in:
sysctl -w net.inet.tcp.delayed_ack=0
This is the same as what is in /etc/sysctl.conf, but the setting will be lost after a reboot. Enjoy!
    •    
  • Currently 2.71 / 5
  You rated: 2 / 5 (7 votes cast)
 
[99,379 views]  

Speed up Samba file copying speeds | 20 comments | Create New Account
Click here to return to the 'Speed up Samba file copying speeds' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Speed up Samba file copying speeds
Authored by: mistersquid on Nov 11, '05 07:27:56AM

Since updating to 10.4.3 (though my troubles may be unrelated to that), I've noticed that AFP performance has dropped dramatically. I have my music library AFPd over the Internet with a 450 Mb upstream. This used to be fine for iTunes, but after updating the remote machine to 10.4.3, iTunes does nothing but stutter.

I'm not in front of that machine to test whether this hint helps, but I'm hoping. Looking at the preference that gets set, I'm imagining that the delayed acknowledgments over TCP affect more than just Samba.

Yes?



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: smsm1@hw.ac.uk on Nov 11, '05 08:08:43AM

Are you able to ssh into the mac with the AFP server? If you have admin privileges, you could then run the second command and get the same effect.



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: dispensa on Nov 11, '05 07:38:30AM

Delayed ACK is important in TCP flow control; the server should only stop sending data if the TCP window is full. Do you have any packet captures (e.g. using Ethereal) that illustrate that delayed ACK is the problem? It certainly shouldn't be if the server is Windows-based, and I'd be surprised if it were for Linux.

Can you post details?



[ Reply to This | # ]
More tcp/ip madness
Authored by: fri2219 on Nov 11, '05 04:22:55PM
I use the following for firewire networking (with jumbo packets). Everything (including no ack) works fine as long as you have a small, lightly used network segment.

I wouldn't try this where you had to worry about collisions, time-outs and packet re-assembly.

#!/bin/sh

##
# network prefs script
#
##

# network tuning

# don't delay sending acks to syns
/usr/sbin/sysctl -w net.inet.tcp.delayed_ack=0

# increase the size of tcp & udp windows
/usr/sbin/sysctl -w net.inet.ip.portrange.last=65535
/usr/sbin/sysctl -w net.inet.tcp.sendspace=65535
/usr/sbin/sysctl -w net.inet.tcp.recvspace=65535
/usr/sbin/sysctl -w net.inet.udp.recvspace=65535
/usr/sbin/sysctl -w net.inet.udp.maxdgram=57344
/usr/sbin/sysctl -w net.inet.tcp.rfc1323=1
/usr/sbin/sysctl -w net.local.stream.recvspace=65535
/usr/sbin/sysctl -w net.local.stream.sendspace=65535

# set buffer size for sockets
/usr/sbin/sysctl -w kern.ipc.maxsockbuf=2097152



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: aylwinndp on Nov 11, '05 08:16:25AM

/etc/sysctl.conf doesn't exist for me in 10.3.9 - is it safe/useful to create it?



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: victory on Nov 11, '05 09:20:10AM
Yes, just open a shell via Terminal.app and use your favorite text editor (emacs/vi/nano/etc) or use BBEdit. You'll need privileges to write to /etc (think sudo).

- The file /etc/sysconf.conf doesn't exist by default (on client versions of OSX anyhow), so you'll have to create it.

- For more info, see these hints also.



[
Reply to This | # ]

Speed up Samba file copying speeds
Authored by: TriNeuro on Nov 11, '05 09:27:54AM

And you're sure it's not just the samba configuration? Check the man pages for the "large readwrite" setting and you'll understand what I'm pointing towards. I commented on a older hint about this before, but the gist is to edit smb.conf and set: large readwrite = no in the global settings.

I'm not sure if this is still a problem in Tiger, but earlier releases had large readwrite set to yes by default, which is wrong until the system is fully 64-bit compatible.



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: aegisdesign on Nov 11, '05 09:46:29AM

There's no 'largerewrite' setting at all in my Tiger (10.4.3) config so I suspect they've fixed it.



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: rasp on Nov 12, '05 03:33:00PM

Actually, it is the default setting for tiger's samba, if you do
$ testparm -vs |grep readwrite
you will see...
large readwrite = Yes
so, if you want that set to no, add the line to the general secion of smb.conf.



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: MorganizeIT on Nov 14, '05 06:39:14AM

I added the 'large readwrite' directive to my Samba config and there was no noticeable change in speed.

I turned off delayed acks and my file copy speed jumped from ~50KB to ~180KB.

I'm using 100bT ethernet with a PowerBook.



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: Shawn Parr on Nov 11, '05 06:24:02PM

My guess is that the original poster is connecting to a Windows Based server. Windows does not do delayed ACK properly, for more info you can find lots of info on it via Google. Often this is done on the server side when your server is not windows and your clients are.

That being said, be careful! This could cause the rest of your traffic to suffer! If most of your traffic is to a Windows server it may not be a big deal, but if your traffic is more generalized than your SMB being up and the rest being down may not be that pleasant.



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: drcorbeille on Nov 12, '05 06:27:16AM

As a recent switcher, I just discovered this site and this hint is exactly what I needed. I tried connecting my powerbook through a cable to my network, thinking it was the airport that was so slow. With your help i now copy a CD iso in 8-9 minutes instead of nearly one hour!



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: acdha on Nov 12, '05 07:20:37AM
Here's what I keep in /etc/sysctl.conf on our lab machines. Note that we *want* delayed ACKs on - in combination with the RFC1323 window sizes that's one of the things which helps us get reasonable gigabit transfers - ~700Mbs on a PowerBook, saturation on a G5.
net.inet.tcp.mssdflt=1460 
net.inet.tcp.sendspace=262144 
net.inet.tcp.recvspace=262144 
net.inet.udp.recvspace=74848
net.inet.udp.maxdgram=65535
net.inet.tcp.rfc1323=1 
net.inet.tcp.newreno=1 
net.inet.tcp.always_keepalive=1 
net.inet.tcp.keepidle=3600 
net.inet.tcp.keepintvl=150 
net.inet.tcp.slowstart_flightsize=4
net.inet.tcp.strict_rfc1948=1
net.inet.tcp.delayed_ack=1
We also tweak keepalives simply to avoid stale connections hanging around in some apps which we have - this is probably irrelevant for most people.

[ Reply to This | # ]
Don't su to root
Authored by: forman on Nov 12, '05 10:56:44AM
It is considered bad form to su to root by using sudo su -. One should never log in as root, if it's not absolutely necessary. This is why the sudo command was created in the first place, to allow a user to execute single commands as root. (sudo stands for "super user do".)

Thus, one should simply type the command sudo sysctl -w net.inet.tcp.delayed_ack=0.

Michael.

[ Reply to This | # ]
Don't su to root
Authored by: hattori on Nov 15, '05 07:33:41AM

OMG... Why do you have to be such a *censored*? People can be responsible and su to root and do the stuff they have to do without messing everything up.
sudo is good for n00bs...



[ Reply to This | # ]
Don't su to root
Authored by: evansj on Nov 15, '05 08:02:53AM
But sudo su - is completely redundant in this case. If you want a root shell, just use sudo -s. No need to run two programs when one will do exactly what you want.

[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: clith on Nov 15, '05 09:20:44AM
This was talked about in this hint last year.

[ Reply to This | # ]
Quick & Easy -- use BroadbandOptimizer
Authored by: mikerose on Nov 17, '05 12:41:04PM
As a matter of habit, I run BroadbandOptimizer after updates to Mac OS X Server; it takes care of the necessary ACK adjustments with no muss, no fuss.

Enigmarelle's BroadbandOptimizer

This solution was arrived at after much frustration and gnashing of teeth following the Jaguar-->Panther server update, and with the help of Apple's support fora.

[ Reply to This | # ]

Speed up Samba file copying speeds
Authored by: Baguerra on Nov 30, '05 01:11:11AM

Well, the comments to this hint helped solve the Mac <-> Linux samba performance problem I have had since I switched from a PC to Mac over six months ago, so I had no choice but to get an account and share my results with others...

Short version:
- Typing "sysctl -w net.inet.tcp.delayed_ack=0" on the Mac did nothing
- Adding "large readwrite = no" to smb.conf on the Mac did nothing
- Adding "large readwrite = no" to smb.conf on Linux fixed the problem

My home network consists of a PowerBook 15" 1.67GHz running 10.4.3 and an old P3 400MHz laptop running Ubuntu Linux v5.10. I was able to get the two macines connected via Samba easily enough, but performance was less than spectacular. Adding the "large readwrite = no" entry to the smb.conf on the Linux box dramatically improved performance. Using a folder containing 38 images totaling 10MB in size, transfers were as follows...

Before the change:
Linux -> Mac: 1 minute
Mac -> Linux: 2 minutes

After the change:
Linux -> Mac: < 10 seconds
Mac -> Linux: < 10 seconds

I couldn't be happier, and hopefully this will help solve the problem for others as well. Thanks to everyone who took the time to contribute to this thread!



[ Reply to This | # ]
Speed up Samba file copying speeds
Authored by: Baguerra on Nov 30, '05 03:53:17AM

One quick clarification on my last post for those that might get confused...

Adding the "large readwrite = no" line to a machine's smb.conf file will increase the performance of THAT machine when it is acting as a server. In the examples I gave above, I was doing all of the copying to and from the Linux box from my Mac, so the change only had to be made on the Linux box (since it is the server). When I tested in reverse (copying files to and from the Mac while using my Linux box), performance was poor again. Adding the "large readwrite = no" line to the Mac smb.conf smoothed things out as expected.

So, in short, change smb.conf on both machines.

I'm sure 99% of the people here know this already, but I just wanted to avoid any potential confusion. Also, I do not have a Windows box on my network, so I can not say if this change will affect file sharing performance with those machines.



[ Reply to This | # ]