[dbench @ tridge@samba.org-20080709030609-aepl7hrdkn7mpfoz]
[tridge/dbench.git] / README
1 Emulating Netbench
2 ==================
3
4 Netbench is a terrible benchmark, but it's an "industry standard" and
5 it's what is used in the press to rate windows fileservers like Samba
6 and WindowsNT.
7
8 The big problem with netbench for the open source community is that
9 very few people who work on open source software have the facilities
10 to run it properly. You need a lab with between 60 and 150 windows PC,
11 all on switched fast ethernet and a really grunty server (say a quad
12 xeon with 1GB ram and hardware raid). Then you need some way to nurse
13 all those machines along so they will run a very fussy benchmark suite
14 without crashing. Not easy and very expensive. Only one person in the
15 open source community that I know of has access to such a lab (Jeremy
16 Allison at SGI).
17
18 In order for the development methodologies of the open source
19 community to work we need to be able to run this benchmark in an
20 environment that a bunch of us have access to. We need the source to
21 the benchmark so we can see what it does. We need to be able to split
22 it into pieces to look for individual bottlenecks. In short, we need
23 to open up netbench to the masses.
24
25 To do this I have written three tools, dbench, tbench and
26 smbtorture. All three read a load description file called client.txt
27 that was derived from a network sniffer dump of a real netbench
28 run. client.txt is about 4MB and describes the 90 thousand operations
29 that a netbench client does in a typical netbench run. They parse
30 client.txt and use it to produce the same load without having to buy a
31 huge lab. They can simulate any number of simultaneous clients.
32
33 client.txt must either be in the working directory, or specified on
34 the command line with the -c option.
35
36 dbench
37 ------
38
39 dbench produces only the filesystem load. It does all the same IO
40 calls that the smbd server in Samba would produce when confronted with
41 a netbench run. It does no networking calls. 
42
43 You can get dbench from ftp://samba.org/pub/tridge/dbench/
44 You run it as "dbench N" where N is the number of clients to
45 simulate. It gives out three numbers like this (this is from a 144
46 client run on a quad xeon box):
47
48         Throughput 40.6701 MB/sec (NB=50.8376 MB/sec  406.701 MBit/sec)
49
50 the first is the true throughput as seen by dbench. The second and
51 third numbers are "netbench scaled" numbers that give the throughput
52 that would be seen by Win9X boxes after taking into account the client
53 file cacheing performed by oplocks. They are given in both MB/sec and
54 MBit/sec as different netbench reports use different scales.
55
56 tbench
57 ------
58
59 tbench produces only the TCP and process load. It does the same socket
60 calls that smbd would do under a netbench load. It does no filesystem
61 calls. The idea behind tbench is to eliminate smbd from the netbench
62 test, as though the smbd code could be made infinately fast. The
63 throughput results of tbench tell us how fast a netbench run could go
64 if we eliminated all filesystem IO and SMB packet processing.  tbench
65 is built as part of the dbench package.
66
67 To run tbench first run tbench_srv on the server. Then run "tbench N SERVER"
68 on the client. N is the number of clients to simulate and SERVER is
69 the hostname of the server. The results are given in the same format
70 as dbench.
71
72 smbtorture
73 ----------
74
75 smbtorture is the stress tester from the Samba suite. I've recently
76 added a stress test that allows you to simulate the full netbench
77 benchmark, including all network traffic and filesystem IO.
78
79 To run smbtorture you first need to install Samba version 2.0.X. The
80 binary distrubtions at ftp://ftp.samba.org/pub/samba/bin-pkgs/redhat/
81 would do fine if you don't want to compile it yourself. Then setup a
82 netbench share on the fastest disk you have, making sure you have at
83 least 25MB free per simulated client. The simplest smb.conf would look
84 something like this:
85
86 [global]
87         security = share
88
89 [netbench]
90         path = /data/netbench
91         read only = no
92         guest ok = yes
93
94 Then you need smbtorture. You can either grab a precompiled i386
95 Redhat5.2 binary from ftp://samba.org/pub/tridge/dbench/smbtorture.gz
96 or you can follow the instructions at http://samba.org/cvs.html to
97 download the SAMBA_2_0 branch of the Samba cvs tree and use 
98 "make smbtorture" to build it.
99
100 Finally, you'll need client.txt from
101 ftp://samba.org/pub/tridge/dbench/dbench.tgz in the same directory
102 that you run smbtorture from.
103
104 To run it you do this:
105
106   smbtorture //localhost/netbench -U% -N 32 NBW95
107
108 that will run a 32 client load. You can, of course, also run
109 smbtorture against a dfferent SMB server (such as a NT server) to give
110 comparitive results for any client load that the server can handle.
111
112 Even better is to run smbtorture on one machine and smbd on another,
113 connected by a very fast network (such as gigabit ethernet). That will
114 stop the smbtorture code itself from loading the server and will also
115 test the network driver instead of the loopback driver.
116
117 results
118 -------
119
120 To give you an idea of what to expect here are some results on a quad
121 xeon machine running Linux 2.2.9 with 1GB of memory (it has 4GB but
122 Linux only uses 1GB by default). The machine also has a 45GB hardware
123 raid system and a Alteon AceNIC gigabit network card.
124
125 The results below are in netbench MB/sec (the NB= number in the
126 result). Multiply by 8 to get the MBit/sec numbers that Mindcraft used
127 in their graphs. The first column is the number of simulated clients,
128 the second is the result.
129
130 With dbench I get:
131
132 16  118
133 32  103
134 48  81
135 64  74
136 80  67
137 96  57
138 112 57
139 128 54
140
141 With tbench on loopback I get:
142
143 16  31
144 32  30
145 48  29
146 64  29
147 80  28
148
149 With tbench running across the gigabit network (using a dual
150 processor Origin200 as the client) I get:
151
152 16  29
153 32  29
154 48  29
155 64  29
156
157
158 With smbtorture running over loopback I get:
159
160 16  18
161 32  18
162 48  18
163 64  17
164 80  16
165
166 With smbtorture running across the gigabit network (using a dual
167 processor Origin200 as the client) I get:
168
169 16  16
170 32  20
171 48  21
172 64  20
173 80  19
174
175 With smbtorture running across the gigabit network but with smbd
176 modified so that write_file() and read_file() are null operations
177 (which eliminates the file IO) I get:
178
179 16  17
180 32  22
181 48  24
182 64  24
183 80  24
184
185
186 The above results show that, at least for this hardware configuration,
187 the problem isn't the filesystem code or the raid drivers. More tests
188 will be needed to find out exactly what the problem is but it looks
189 like a TCP scaling problem.
190
191 comparison with NT
192 ------------------
193
194 Hopefully Jeremy will be able to run smbtorture against NT on the same
195 hardwre sometime in the next week so we have direct numbers for
196 comparison, but from looking at the mindcraft numbers under netbench
197 we would expect NT to get about the following:
198
199 16  8
200 32  14
201 48  21
202 64  27
203 80  31
204
205 so we do well by comparison with small client loads but fall behind
206 quite a lot with large loads. Note that the numbers in the mindcraft
207 report for Linux/Samba are quite a long way behind what I give above
208 because mindcraft did a hopeless job of tuning Linux/Samba.
209
210 comparison with netbench
211 ------------------------
212
213 An initial comparison with real netbench results shows that smbtorture
214 does produce very similar throughput numbers. They aren't exactly the
215 same but they are similar enough for us to target our tuning efforts
216 and expect to see improvements reflected in real netbench runs. When
217 we find something that looks promising we can get Jeremy to run a real
218 netbench test.
219
220
221 a quick hack
222 ------------
223
224 the tbench results really pointed at the problem being the Linux TCP
225 stack. I made a quick (and very unsafe!) hack to Samba and the Linux
226 kernel to see if I could remove the lock_kernel() in sys_sendto() and
227 sys_recvfrom() for smbd processes by passing a MSG_NOLOCK flag in
228 send() and recv(). That gave an enormous improvement in the loopback
229 tbench results:
230
231 16  31->51
232 32  30->49
233 48  29->47
234 64  29->46
235 80  28->44
236
237 and in the loopback smbtorture results I also saw a big improvement:
238
239 16  18->26
240 32  18->27
241 48  18->26
242 64  17->25
243 80  16->24
244
245 that's a 50% improvement. I suspect the numbers will be higher with a
246 real netbench run as it won't have the overhead of running 80
247 smbtorture clients on the same box as the server.
248
249
250 realistic load?
251 ---------------
252
253 One question some people may ask is whether the above represents a
254 realistic load on a fileserver. It doesn't. Nearly 90% of the
255 read/write IO operations in netbench are writes whereas in a "normal"
256 office load reads dominate. Also, the load is *much* higher than a
257 normal office PC would put on a server. There aren't many office PCs
258 that write over a hundred megabytes of data to a server in a few
259 minutes, unless maybe they are copying a CD.
260
261 That doesn't mean the benchmark is useless, it just means you
262 shouldn't use this for purchasing decisions unless you really
263 understand the results and how they relate to your environment.
264
265
266 license
267 -------
268
269 smbtorture and dbench are released under the terms of the GNU Public
270 License version 3 or later.
271
272
273 Andrew Tridgell
274 tridge@samba.org