]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/doc/smm/05.fastfs/4.t
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / share / doc / smm / 05.fastfs / 4.t
1 .\" Copyright (c) 1986, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)4.t 8.1 (Berkeley) 6/8/93
29 .\"
30 .ds RH Performance
31 .NH 
32 Performance
33 .PP
34 Ultimately, the proof of the effectiveness of the
35 algorithms described in the previous section
36 is the long term performance of the new file system.
37 .PP
38 Our empirical studies have shown that the inode layout policy has
39 been effective.
40 When running the ``list directory'' command on a large directory
41 that itself contains many directories (to force the system
42 to access inodes in multiple cylinder groups),
43 the number of disk accesses for inodes is cut by a factor of two.
44 The improvements are even more dramatic for large directories
45 containing only files,
46 disk accesses for inodes being cut by a factor of eight.
47 This is most encouraging for programs such as spooling daemons that
48 access many small files,
49 since these programs tend to flood the
50 disk request queue on the old file system.
51 .PP
52 Table 2 summarizes the measured throughput of the new file system.
53 Several comments need to be made about the conditions under which these
54 tests were run.
55 The test programs measure the rate at which user programs can transfer
56 data to or from a file without performing any processing on it.
57 These programs must read and write enough data to
58 insure that buffering in the
59 operating system does not affect the results.
60 They are also run at least three times in succession;
61 the first to get the system into a known state
62 and the second two to insure that the 
63 experiment has stabilized and is repeatable.
64 The tests used and their results are
65 discussed in detail in [Kridle83]\(dg.
66 .FS
67 \(dg A UNIX command that is similar to the reading test that we used is
68 ``cp file /dev/null'', where ``file'' is eight megabytes long.
69 .FE
70 The systems were running multi-user but were otherwise quiescent.
71 There was no contention for either the CPU or the disk arm.
72 The only difference between the UNIBUS and MASSBUS tests
73 was the controller.
74 All tests used an AMPEX Capricorn 330 megabyte Winchester disk.
75 As Table 2 shows, all file system test runs were on a VAX 11/750.
76 All file systems had been in production use for at least
77 a month before being measured.
78 The same number of system calls were performed in all tests;
79 the basic system call overhead was a negligible portion of
80 the total running time of the tests.
81 .KF
82 .DS B
83 .TS
84 box;
85 c c|c s s
86 c c|c c c.
87 Type of Processor and   Read
88 File System     Bus Measured    Speed   Bandwidth       % CPU
89 _
90 old 1024        750/UNIBUS      29 Kbytes/sec   29/983 3%       11%
91 new 4096/1024   750/UNIBUS      221 Kbytes/sec  221/983 22%     43%
92 new 8192/1024   750/UNIBUS      233 Kbytes/sec  233/983 24%     29%
93 new 4096/1024   750/MASSBUS     466 Kbytes/sec  466/983 47%     73%
94 new 8192/1024   750/MASSBUS     466 Kbytes/sec  466/983 47%     54%
95 .TE
96 .ce 1
97 Table 2a \- Reading rates of the old and new UNIX file systems.
98 .TS
99 box;
100 c c|c s s
101 c c|c c c.
102 Type of Processor and   Write
103 File System     Bus Measured    Speed   Bandwidth       % CPU
104 _
105 old 1024        750/UNIBUS      48 Kbytes/sec   48/983 5%       29%
106 new 4096/1024   750/UNIBUS      142 Kbytes/sec  142/983 14%     43%
107 new 8192/1024   750/UNIBUS      215 Kbytes/sec  215/983 22%     46%
108 new 4096/1024   750/MASSBUS     323 Kbytes/sec  323/983 33%     94%
109 new 8192/1024   750/MASSBUS     466 Kbytes/sec  466/983 47%     95%
110 .TE
111 .ce 1
112 Table 2b \- Writing rates of the old and new UNIX file systems.
113 .DE
114 .KE
115 .PP
116 Unlike the old file system,
117 the transfer rates for the new file system do not
118 appear to change over time.
119 The throughput rate is tied much more strongly to the
120 amount of free space that is maintained.
121 The measurements in Table 2 were based on a file system
122 with a 10% free space reserve.
123 Synthetic work loads suggest that throughput deteriorates
124 to about half the rates given in Table 2 when the file
125 systems are full.
126 .PP
127 The percentage of bandwidth given in Table 2 is a measure
128 of the effective utilization of the disk by the file system.
129 An upper bound on the transfer rate from the disk is calculated 
130 by multiplying the number of bytes on a track by the number
131 of revolutions of the disk per second.
132 The bandwidth is calculated by comparing the data rates
133 the file system is able to achieve as a percentage of this rate.
134 Using this metric, the old file system is only
135 able to use about 3\-5% of the disk bandwidth,
136 while the new file system uses up to 47%
137 of the bandwidth.
138 .PP
139 Both reads and writes are faster in the new system than in the old system.
140 The biggest factor in this speedup is because of the larger
141 block size used by the new file system.
142 The overhead of allocating blocks in the new system is greater
143 than the overhead of allocating blocks in the old system,
144 however fewer blocks need to be allocated in the new system
145 because they are bigger.
146 The net effect is that the cost per byte allocated is about
147 the same for both systems.
148 .PP
149 In the new file system, the reading rate is always at least
150 as fast as the writing rate.
151 This is to be expected since the kernel must do more work when
152 allocating blocks than when simply reading them.
153 Note that the write rates are about the same 
154 as the read rates in the 8192 byte block file system;
155 the write rates are slower than the read rates in the 4096 byte block
156 file system.
157 The slower write rates occur because
158 the kernel has to do twice as many disk allocations per second,
159 making the processor unable to keep up with the disk transfer rate.
160 .PP
161 In contrast the old file system is about 50%
162 faster at writing files than reading them.
163 This is because the write system call is asynchronous and
164 the kernel can generate disk transfer
165 requests much faster than they can be serviced,
166 hence disk transfers queue up in the disk buffer cache.
167 Because the disk buffer cache is sorted by minimum seek distance,
168 the average seek between the scheduled disk writes is much
169 less than it would be if the data blocks were written out
170 in the random disk order in which they are generated.
171 However when the file is read,
172 the read system call is processed synchronously so
173 the disk blocks must be retrieved from the disk in the
174 non-optimal seek order in which they are requested.
175 This forces the disk scheduler to do long
176 seeks resulting in a lower throughput rate.
177 .PP
178 In the new system the blocks of a file are more optimally
179 ordered on the disk.
180 Even though reads are still synchronous, 
181 the requests are presented to the disk in a much better order.
182 Even though the writes are still asynchronous,
183 they are already presented to the disk in minimum seek
184 order so there is no gain to be had by reordering them.
185 Hence the disk seek latencies that limited the old file system
186 have little effect in the new file system.
187 The cost of allocation is the factor in the new system that 
188 causes writes to be slower than reads.
189 .PP
190 The performance of the new file system is currently
191 limited by memory to memory copy operations
192 required to move data from disk buffers in the
193 system's address space to data buffers in the user's
194 address space.  These copy operations account for
195 about 40% of the time spent performing an input/output operation.
196 If the buffers in both address spaces were properly aligned, 
197 this transfer could be performed without copying by
198 using the VAX virtual memory management hardware.
199 This would be especially desirable when transferring
200 large amounts of data.
201 We did not implement this because it would change the
202 user interface to the file system in two major ways:
203 user programs would be required to allocate buffers on page boundaries, 
204 and data would disappear from buffers after being written.
205 .PP
206 Greater disk throughput could be achieved by rewriting the disk drivers
207 to chain together kernel buffers.
208 This would allow contiguous disk blocks to be read
209 in a single disk transaction.
210 Many disks used with UNIX systems contain either
211 32 or 48 512 byte sectors per track.
212 Each track holds exactly two or three 8192 byte file system blocks,
213 or four or six 4096 byte file system blocks.
214 The inability to use contiguous disk blocks
215 effectively limits the performance
216 on these disks to less than 50% of the available bandwidth.
217 If the next block for a file cannot be laid out contiguously,
218 then the minimum spacing to the next allocatable
219 block on any platter is between a sixth and a half a revolution.
220 The implication of this is that the best possible layout without
221 contiguous blocks uses only half of the bandwidth of any given track.
222 If each track contains an odd number of sectors, 
223 then it is possible to resolve the rotational delay to any number of sectors
224 by finding a block that begins at the desired 
225 rotational position on another track.
226 The reason that block chaining has not been implemented is because it
227 would require rewriting all the disk drivers in the system,
228 and the current throughput rates are already limited by the
229 speed of the available processors.
230 .PP
231 Currently only one block is allocated to a file at a time.
232 A technique used by the DEMOS file system
233 when it finds that a file is growing rapidly,
234 is to preallocate several blocks at once,
235 releasing them when the file is closed if they remain unused.
236 By batching up allocations, the system can reduce the
237 overhead of allocating at each write,
238 and it can cut down on the number of disk writes needed to
239 keep the block pointers on the disk
240 synchronized with the block allocation [Powell79].
241 This technique was not included because block allocation 
242 currently accounts for less than 10% of the time spent in
243 a write system call and, once again, the
244 current throughput rates are already limited by the speed
245 of the available processors.
246 .ds RH Functional enhancements
247 .sp 2
248 .ne 1i