fix issue with password changes done via NTLMSSP
[Samba.git] / docs / textdocs / Speed.txt
blob325376ac250017e33f477af3c902001743690baf
1 !==
2 !== Speed.txt for Samba release 2.2.0-alpha3 24 Mar 2001
3 !==
5 Subject:        Samba performance issues
6 ============================================================================
8 This file tries to outline the ways to improve the speed of a Samba server.
10 COMPARISONS
11 -----------
13 The Samba server uses TCP to talk to the client. Thus if you are
14 trying to see if it performs well you should really compare it to
15 programs that use the same protocol. The most readily available
16 programs for file transfer that use TCP are ftp or another TCP based
17 SMB server.
19 If you want to test against something like a NT or WfWg server then
20 you will have to disable all but TCP on either the client or
21 server. Otherwise you may well be using a totally different protocol
22 (such as Netbeui) and comparisons may not be valid.
24 Generally you should find that Samba performs similarly to ftp at raw
25 transfer speed. It should perform quite a bit faster than NFS,
26 although this very much depends on your system.
28 Several people have done comparisons between Samba and Novell, NFS or
29 WinNT. In some cases Samba performed the best, in others the worst. I
30 suspect the biggest factor is not Samba vs some other system but the
31 hardware and drivers used on the various systems. Given similar
32 hardware Samba should certainly be competitive in speed with other
33 systems.
36 OPLOCKS
37 -------
39 Oplocks are the way that SMB clients get permission from a server to
40 locally cache file operations. If a server grants an oplock
41 (opportunistic lock) then the client is free to assume that it is the
42 only one accessing the file and it will agressively cache file
43 data. With some oplock types the client may even cache file open/close
44 operations. This can give enormous performance benefits.
46 With the release of Samba 1.9.18 we now correctly support opportunistic 
47 locks. This is turned on by default, and can be turned off on a share-
48 by-share basis by setting the parameter :
50 oplocks = False
52 We recommend that you leave oplocks on however, as current benchmark
53 tests with NetBench seem to give approximately a 30% improvement in
54 speed with them on. This is on average however, and the actual 
55 improvement seen can be orders of magnitude greater, depending on
56 what the client redirector is doing.
58 Previous to Samba 1.9.18 there was a 'fake oplocks' option. This
59 option has been left in the code for backwards compatibility reasons
60 but it's use is now deprecated. A short summary of what the old
61 code did follows.
63 LEVEL2 OPLOCKS
64 --------------
66 With Samba 2.0.5 a new capability - level2 (read only) oplocks is
67 supported (although the option is off by default - see the smb.conf
68 man page for details). Turning on level2 oplocks (on a share-by-share basis)
69 by setting the parameter :
71 level2 oplocks = true 
73 should speed concurrent access to files that are not commonly written
74 to, such as application serving shares (ie. shares that contain common
75 .EXE files - such as a Microsoft Office share) as it allows clients to
76 read-ahread cache copies of these files.
78 Old 'fake oplocks' option - deprecated.
79 ---------------------------------------
81 Samba can also fake oplocks, by granting a oplock whenever a client 
82 asks for one. This is controlled using the smb.conf option "fake 
83 oplocks". If you set "fake oplocks = yes" then you are telling the 
84 client that it may agressively cache the file data for all opens.
86 Enabling 'fake oplocks' on all read-only shares or shares that you know
87 will only be accessed from one client at a time you will see a big
88 performance improvement on many operations. If you enable this option
89 on shares where multiple clients may be accessing the files read-write
90 at the same time you can get data corruption.
92 SOCKET OPTIONS
93 --------------
95 There are a number of socket options that can greatly affect the
96 performance of a TCP based server like Samba.
98 The socket options that Samba uses are settable both on the command
99 line with the -O option, or in the smb.conf file.
101 The "socket options" section of the smb.conf manual page describes how
102 to set these and gives recommendations.
104 Getting the socket options right can make a big difference to your
105 performance, but getting them wrong can degrade it by just as
106 much. The correct settings are very dependent on your local network.
108 The socket option TCP_NODELAY is the one that seems to make the
109 biggest single difference for most networks. Many people report that
110 adding "socket options = TCP_NODELAY" doubles the read performance of
111 a Samba drive. The best explanation I have seen for this is that the
112 Microsoft TCP/IP stack is slow in sending tcp ACKs.
115 READ SIZE
116 ---------
118 The option "read size" affects the overlap of disk reads/writes with
119 network reads/writes. If the amount of data being transferred in
120 several of the SMB commands (currently SMBwrite, SMBwriteX and
121 SMBreadbraw) is larger than this value then the server begins writing
122 the data before it has received the whole packet from the network, or
123 in the case of SMBreadbraw, it begins writing to the network before
124 all the data has been read from disk.
126 This overlapping works best when the speeds of disk and network access
127 are similar, having very little effect when the speed of one is much
128 greater than the other.
130 The default value is 16384, but very little experimentation has been
131 done yet to determine the optimal value, and it is likely that the best
132 value will vary greatly between systems anyway. A value over 65536 is
133 pointless and will cause you to allocate memory unnecessarily.
136 MAX XMIT
137 --------
139 At startup the client and server negotiate a "maximum transmit" size,
140 which limits the size of nearly all SMB commands. You can set the
141 maximum size that Samba will negotiate using the "max xmit = " option
142 in smb.conf. Note that this is the maximum size of SMB request that 
143 Samba will accept, but not the maximum size that the *client* will accept.
144 The client maximum receive size is sent to Samba by the client and Samba
145 honours this limit.
147 It defaults to 65536 bytes (the maximum), but it is possible that some
148 clients may perform better with a smaller transmit unit. Trying values
149 of less than 2048 is likely to cause severe problems.
151 In most cases the default is the best option.
154 LOCKING
155 -------
157 By default Samba does not implement strict locking on each read/write
158 call (although it did in previous versions). If you enable strict
159 locking (using "strict locking = yes") then you may find that you
160 suffer a severe performance hit on some systems.
162 The performance hit will probably be greater on NFS mounted
163 filesystems, but could be quite high even on local disks.
166 SHARE MODES
167 -----------
169 Some people find that opening files is very slow. This is often
170 because of the "share modes" code needed to fully implement the dos
171 share modes stuff. You can disable this code using "share modes =
172 no". This will gain you a lot in opening and closing files but will
173 mean that (in some cases) the system won't force a second user of a
174 file to open the file read-only if the first has it open
175 read-write. For many applications that do their own locking this
176 doesn't matter, but for some it may. Most Windows applications
177 depend heavily on "share modes" working correctly and it is
178 recommended that the Samba share mode support be left at the
179 default of "on".
181 The share mode code in Samba has been re-written in the 1.9.17
182 release following tests with the Ziff-Davis NetBench PC Benchmarking
183 tool. It is now believed that Samba 1.9.17 implements share modes
184 similarly to Windows NT.
186 NOTE: In the most recent versions of Samba there is an option to use
187 shared memory via mmap() to implement the share modes. This makes
188 things much faster. See the Makefile for how to enable this.
191 LOG LEVEL
192 ---------
194 If you set the log level (also known as "debug level") higher than 2
195 then you may suffer a large drop in performance. This is because the
196 server flushes the log file after each operation, which can be very
197 expensive. 
200 WIDE LINKS
201 ----------
203 The "wide links" option is now enabled by default, but if you disable
204 it (for better security) then you may suffer a performance hit in
205 resolving filenames. The performance loss is lessened if you have
206 "getwd cache = yes", which is now the default.
209 READ RAW
210 --------
212 The "read raw" operation is designed to be an optimised, low-latency
213 file read operation. A server may choose to not support it,
214 however. and Samba makes support for "read raw" optional, with it
215 being enabled by default.
217 In some cases clients don't handle "read raw" very well and actually
218 get lower performance using it than they get using the conventional
219 read operations. 
221 So you might like to try "read raw = no" and see what happens on your
222 network. It might lower, raise or not affect your performance. Only
223 testing can really tell.
226 WRITE RAW
227 ---------
229 The "write raw" operation is designed to be an optimised, low-latency
230 file write operation. A server may choose to not support it,
231 however. and Samba makes support for "write raw" optional, with it
232 being enabled by default.
234 Some machines may find "write raw" slower than normal write, in which
235 case you may wish to change this option.
237 READ PREDICTION
238 ---------------
240 Samba can do read prediction on some of the SMB commands. Read
241 prediction means that Samba reads some extra data on the last file it
242 read while waiting for the next SMB command to arrive. It can then
243 respond more quickly when the next read request arrives.
245 This is disabled by default. You can enable it by using "read
246 prediction = yes".
248 Note that read prediction is only used on files that were opened read
249 only.
251 Read prediction should particularly help for those silly clients (such
252 as "Write" under NT) which do lots of very small reads on a file.
254 Samba will not read ahead more data than the amount specified in the
255 "read size" option. It always reads ahead on 1k block boundaries.
258 MEMORY MAPPING
259 --------------
261 Samba supports reading files via memory mapping them. One some
262 machines this can give a large boost to performance, on others it
263 makes not difference at all, and on some it may reduce performance.
265 To enable you you have to recompile Samba with the -DUSE_MMAP option
266 on the FLAGS line of the Makefile.
268 Note that memory mapping is only used on files opened read only, and
269 is not used by the "read raw" operation. Thus you may find memory
270 mapping is more effective if you disable "read raw" using "read raw =
271 no".
274 SLOW CLIENTS
275 ------------
277 One person has reported that setting the protocol to COREPLUS rather
278 than LANMAN2 gave a dramatic speed improvement (from 10k/s to 150k/s).
280 I suspect that his PC's (386sx16 based) were asking for more data than
281 they could chew. I suspect a similar speed could be had by setting
282 "read raw = no" and "max xmit = 2048", instead of changing the
283 protocol. Lowering the "read size" might also help.
286 SLOW LOGINS
287 -----------
289 Slow logins are almost always due to the password checking time. Using
290 the lowest practical "password level" will improve things a lot. You
291 could also enable the "UFC crypt" option in the Makefile.
293 CLIENT TUNING
294 -------------
296 Often a speed problem can be traced to the client. The client (for
297 example Windows for Workgroups) can often be tuned for better TCP
298 performance.
300 See your client docs for details. In particular, I have heard rumours
301 that the WfWg options TCPWINDOWSIZE and TCPSEGMENTSIZE can have a
302 large impact on performance.
304 Also note that some people have found that setting DefaultRcvWindow in
305 the [MSTCP] section of the SYSTEM.INI file under WfWg to 3072 gives a
306 big improvement. I don't know why.
308 My own experience wth DefaultRcvWindow is that I get much better
309 performance with a large value (16384 or larger). Other people have
310 reported that anything over 3072 slows things down enourmously. One
311 person even reported a speed drop of a factor of 30 when he went from
312 3072 to 8192. I don't know why.
314 It probably depends a lot on your hardware, and the type of unix box
315 you have at the other end of the link.
318 MY RESULTS
319 ----------
321 Some people want to see real numbers in a document like this, so here
322 they are. I have a 486sx33 client running WfWg 3.11 with the 3.11b
323 tcp/ip stack. It has a slow IDE drive and 20Mb of ram. It has a SMC
324 Elite-16 ISA bus ethernet card. The only WfWg tuning I've done is to
325 set DefaultRcvWindow in the [MSTCP] section of system.ini to 16384. My
326 server is a 486dx3-66 running Linux. It also has 20Mb of ram and a SMC
327 Elite-16 card. You can see my server config in the examples/tridge/
328 subdirectory of the distribution.
330 I get 490k/s on reading a 8Mb file with copy.
331 I get 441k/s writing the same file to the samba server.
333 Of course, there's a lot more to benchmarks than 2 raw throughput
334 figures, but it gives you a ballpark figure.
336 I've also tested Win95 and WinNT, and found WinNT gave me the best
337 speed as a samba client. The fastest client of all (for me) is
338 smbclient running on another linux box. Maybe I'll add those results
339 here someday ...