Whamcloud - gitweb
LUDOC-114 lnet: LNET/LND credits and flow control
[doc/manual.git] / LustreTuning.xml
1 <?xml version='1.0' encoding='UTF-8'?><chapter xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en-US" xml:id="lustretuning">
2   <title xml:id="lustretuning.title">Lustre Tuning</title>
3   <para>This chapter contains information about tuning Lustre for better performance and includes the following sections:</para>
4   <itemizedlist>
5     <listitem>
6       <para><xref linkend="dbdoclet.50438272_55226"/></para>
7     </listitem>
8     <listitem>
9       <para><xref linkend="dbdoclet.mdstuning"/></para>
10     </listitem>
11     <listitem>
12       <para><xref linkend="dbdoclet.50438272_73839"/></para>
13     </listitem>
14     <listitem>
15       <para><xref linkend="dbdoclet.libcfstuning"/></para>
16     </listitem>
17     <listitem>
18       <para><xref linkend="dbdoclet.lndtuning"/></para>
19     </listitem>
20     <listitem>
21       <para><xref linkend="dbdoclet.nrstuning"/></para>
22     </listitem>
23     <listitem>
24       <para><xref linkend="dbdoclet.50438272_25884"/></para>
25     </listitem>
26     <listitem>
27       <para><xref linkend="dbdoclet.50438272_80545"/></para>
28     </listitem>
29     <listitem>
30       <para><xref linkend="dbdoclet.50438272_45406"/></para>
31     </listitem>
32   </itemizedlist>
33   <note>
34     <para>Many options in Lustre are set by means of kernel module parameters. These parameters are contained in the <literal>/etc/modprobe.d/lustre.conf</literal> file.</para>
35   </note>
36   <section xml:id="dbdoclet.50438272_55226">
37       <title>
38           <indexterm><primary>tuning</primary></indexterm>
39 <indexterm><primary>tuning</primary><secondary>service threads</secondary></indexterm>
40           Optimizing the Number of Service Threads</title>
41     <para>An OSS can have a minimum of two service threads and a maximum of 512 service threads. The
42       number of service threads is a function of how much RAM and how many CPUs are on each OSS node
43       (1 thread / 128MB * num_cpus). If the load on the OSS node is high, new service threads will
44       be started in order to process more requests concurrently, up to 4x the initial number of
45       threads (subject to the maximum of 512). For a 2GB 2-CPU system, the default thread count is
46       32 and the maximum thread count is 128.</para>
47     <para>Increasing the size of the thread pool may help when:</para>
48     <itemizedlist>
49       <listitem>
50         <para>Several OSTs are exported from a single OSS</para>
51       </listitem>
52       <listitem>
53         <para>Back-end storage is running synchronously</para>
54       </listitem>
55       <listitem>
56         <para>I/O completions take excessive time due to slow storage</para>
57       </listitem>
58     </itemizedlist>
59     <para>Decreasing the size of the thread pool may help if:</para>
60     <itemizedlist>
61       <listitem>
62         <para>Clients are overwhelming the storage capacity</para>
63       </listitem>
64       <listitem>
65         <para>There are lots of &quot;slow I/O&quot; or similar messages</para>
66       </listitem>
67     </itemizedlist>
68     <para>Increasing the number of I/O threads allows the kernel and storage to aggregate many writes together for more efficient disk I/O. The OSS thread pool is shared--each thread allocates approximately 1.5 MB (maximum RPC size + 0.5 MB) for internal I/O buffers.</para>
69     <para>It is very important to consider memory consumption when increasing the thread pool size. Drives are only able to sustain a certain amount of parallel I/O activity before performance is degraded, due to the high number of seeks and the OST threads just waiting for I/O. In this situation, it may be advisable to decrease the load by decreasing the number of OST threads.</para>
70     <para>Determining the optimum number of OST threads is a process of trial and error, and varies for each particular configuration. Variables include the number of OSTs on each OSS, number and speed of disks, RAID configuration, and available RAM. You may want to start with a number of OST threads equal to the number of actual disk spindles on the node. If you use RAID, subtract any dead spindles not used for actual data (e.g., 1 of N of spindles for RAID5, 2 of N spindles for RAID6), and monitor the performance of clients during usual workloads. If performance is degraded, increase the thread count and see how that works until performance is degraded again or you reach satisfactory performance.</para>
71     <note>
72       <para>If there are too many threads, the latency for individual I/O requests can become very high and should be avoided. Set the desired maximum thread count permanently using the method described above.</para>
73     </note>
74     <section>
75       <title><indexterm><primary>tuning</primary><secondary>OSS threads</secondary></indexterm>Specifying the OSS Service Thread Count</title>
76       <para>The <literal>oss_num_threads</literal> parameter enables the number of OST service threads to be specified at module load time on the OSS nodes:</para>
77       <screen>options ost oss_num_threads={N}</screen>
78       <para>After startup, the minimum and maximum number of OSS thread counts can be set via the <literal>{service}.thread_{min,max,started}</literal> tunable. To change the tunable at runtime, run:</para>
79       <para><screen>lctl {get,set}_param {service}.thread_{min,max,started}</screen></para>
80       <para>Lustre 2.3 introduced binding service threads to CPU partition. This works in a similar fashion to binding of threads on MDS. MDS thread tuning is covered in <xref linkend="dbdoclet.mdsbinding"/>.</para>
81     <itemizedlist>
82       <listitem>
83         <para><literal>oss_cpts=[EXPRESSION]</literal> binds the default OSS service on CPTs defined by <literal>[EXPRESSION]</literal>.</para>
84       </listitem>
85       <listitem>
86         <para><literal>oss_io_cpts=[EXPRESSION]</literal> binds the IO OSS service on CPTs defined by <literal>[EXPRESSION]</literal>.</para>
87       </listitem>
88     </itemizedlist>
89
90       <para>For further details, see <xref linkend="dbdoclet.50438271_87260"/>.</para>
91     </section>
92     <section xml:id="dbdoclet.mdstuning">
93       <title><indexterm><primary>tuning</primary><secondary>MDS threads</secondary></indexterm>Specifying the MDS Service Thread Count</title>
94       <para>The <literal>mds_num_threads</literal> parameter enables the number of MDS service threads to be specified at module load time on the MDS node:</para>
95       <screen>options mds mds_num_threads={N}</screen>
96       <para>After startup, the minimum and maximum number of MDS thread counts can be set via the <literal>{service}.thread_{min,max,started}</literal> tunable. To change the tunable at runtime, run:</para>
97       <para><screen>lctl {get,set}_param {service}.thread_{min,max,started}</screen></para>
98       <para>For details, see <xref linkend="dbdoclet.50438271_87260"/>.</para>
99       <para>At this time, no testing has been done to determine the optimal number of MDS threads. The default value varies, based on server size, up to a maximum of 32. The maximum number of threads (<literal>MDS_MAX_THREADS</literal>) is 512.</para>
100       <note>
101         <para>The OSS and MDS automatically start new service threads dynamically, in response to server load within a factor of 4. The default value is calculated the same way as before. Setting the <literal>_mu_threads</literal> module parameter disables automatic thread creation behavior.</para>
102       </note>
103         <para>Lustre 2.3 introduced new parameters to provide more control to administrators.</para>
104             <itemizedlist>
105               <listitem>
106                 <para><literal>mds_rdpg_num_threads</literal> controls the number of threads in providing the read page service. The read page service handles file close and readdir operations.</para>
107               </listitem>
108               <listitem>
109                 <para><literal>mds_attr_num_threads</literal> controls the number of threads in providing the setattr service to 1.8 clients.</para>
110               </listitem>
111             </itemizedlist>
112         <note><para>Default values for the thread counts are automatically selected. The values are chosen to best exploit the number of CPUs present in the system and to provide best overall performance for typical workloads.</para></note>
113     </section>
114   </section>
115     <section xml:id="dbdoclet.mdsbinding" condition='l23'>
116       <title><indexterm><primary>tuning</primary><secondary>MDS binding</secondary></indexterm>Binding MDS Service Thread to CPU Partitions</title>
117         <para>With the introduction of Node Affinity (<xref linkend="nodeaffdef"/>) in Lustre 2.3, MDS threads can be bound to particular CPU Partitions (CPTs). Default values for bindings are selected automatically to provide good overall performance for a given CPU count. However, an administrator can deviate from these setting if they choose.</para>
118             <itemizedlist>
119               <listitem>
120                 <para><literal>mds_num_cpts=[EXPRESSION]</literal> binds the default MDS service threads to CPTs defined by <literal>EXPRESSION</literal>. For example <literal>mdt_num_cpts=[0-3]</literal> will bind the MDS service threads to <literal>CPT[0,1,2,3]</literal>.</para>
121               </listitem>
122               <listitem>
123                 <para><literal>mds_rdpg_num_cpts=[EXPRESSION]</literal> binds the read page service threads to CPTs defined by <literal>EXPRESSION</literal>. The read page service handles file close and readdir requests. For example <literal>mdt_rdpg_num_cpts=[4]</literal> will bind the read page threads to <literal>CPT4</literal>.</para>
124               </listitem>
125               <listitem>
126                 <para><literal>mds_attr_num_cpts=[EXPRESSION]</literal> binds the setattr service threads to CPTs defined by <literal>EXPRESSION</literal>.</para>
127               </listitem>
128             </itemizedlist>
129   </section>
130   <section xml:id="dbdoclet.50438272_73839">
131       <title>
132       <indexterm>
133         <primary>LNet</primary>
134         <secondary>tuning</secondary>
135       </indexterm><indexterm>
136         <primary>tuning</primary>
137         <secondary>LNet</secondary>
138       </indexterm>Tuning LNET Parameters</title>
139     <para>This section describes LNET tunables, the use of which may be necessary on some systems to
140       improve performance. To test the performance of your Lustre network, see <xref linkend='lnetselftest'/>.</para>
141     <section remap="h3">
142       <title>Transmit and Receive Buffer Size</title>
143       <para>The kernel allocates buffers for sending and receiving messages on a network.</para>
144       <para><literal>ksocklnd</literal> has separate parameters for the transmit and receive buffers.</para>
145       <screen>options ksocklnd tx_buffer_size=0 rx_buffer_size=0
146 </screen>
147       <para>If these parameters are left at the default value (0), the system automatically tunes the transmit and receive buffer size. In almost every case, this default produces the best performance. Do not attempt to tune these parameters unless you are a network expert.</para>
148     </section>
149     <section remap="h3">
150       <title>Hardware Interrupts (<literal>enable_irq_affinity</literal>)</title>
151       <para>The hardware interrupts that are generated by network adapters may be handled by any CPU in the system. In some cases, we would like network traffic to remain local to a single CPU to help keep the processor cache warm and minimize the impact of context switches. This is helpful when an SMP system has more than one network interface and ideal when the number of interfaces equals the number of CPUs. To enable the <literal>enable_irq_affinity</literal> parameter, enter:</para>
152       <screen>options ksocklnd enable_irq_affinity=1</screen>
153       <para>In other cases, if you have an SMP platform with a single fast interface such as 10Gb Ethernet and more than two CPUs, you may see performance improve by turning this parameter off.</para>
154       <screen>options ksocklnd enable_irq_affinity=0</screen>
155       <para>By default, this parameter is off. As always, you should test the performance to compare the impact of changing this parameter.</para>
156     </section>
157         <section><title><indexterm><primary>tuning</primary><secondary>Network interface binding</secondary></indexterm>Binding Network Interface Against CPU Partitions</title>
158         <para condition="l23">Lustre 2.3 and beyond provide enhanced network interface control. The enhancement means that
159         an administrator can bind an interface to one or more CPU partitions. Bindings are specified
160         as options to the LNET modules. For more information on specifying module options, see <xref
161           linkend="dbdoclet.50438293_15350"/></para>
162 <para condition="l23">For example, <literal>o2ib0(ib0)[0,1]</literal> will ensure that all messages
163         for <literal>o2ib0</literal> will be handled by LND threads executing on
164           <literal>CPT0</literal> and <literal>CPT1</literal>. An additional example might be:
165           <literal>tcp1(eth0)[0]</literal>. Messages for <literal>tcp1</literal> are handled by
166         threads on <literal>CPT0</literal>.</para>
167     </section>
168         <section><title><indexterm><primary>tuning</primary><secondary>Network interface credits</secondary></indexterm>Network Interface Credits</title>
169         <para>Network interface (NI) credits are shared across all CPU partitions (CPT). For example, a
170         machine has 4 CPTs and NI credits is 512, then each partition will has 128 credits. If a
171         large number of CPTs exist on the system, LNET will check and validate the NI credits value
172         for each CPT to ensure each CPT has workable number of credits. For example, a machine has
173         16 CPTs and NI credits is set to 256, then each partition only has 16 credits. 16 NI credits
174         is low and could negatively impact performance. As a result, LNET will automatically make an
175         adjustment to 8*peer_credits (peer_credits is 8 by default), so credits for each partition
176         is still 64.</para>
177         <para>Modifying the NI credit count can be performed by an administrator using
178           <literal>ksoclnd</literal> or <literal>ko2iblnd</literal>. For example:</para>
179         <screen>ksocklnd credits=256</screen>
180         <para>In this example, 256 credits are applied to TCP connections. Applying 256 credits to IB
181         connections can be achieved with:</para>
182         <screen>ko2iblnd credits=256</screen>
183         <note><para condition="l23">From Lustre 2.3 and beyond, it is possible that LNET may
184           revalidate the NI Credits so that the administrator's request does not persist.</para></note>
185         </section>
186         <section><title><indexterm><primary>tuning</primary><secondary>router buffers</secondary></indexterm>Router Buffers</title>
187         <para>Router buffers are shared by all CPU partitions and the client nodes accessing the router.
188         For a machine with a large number of CPTs, the router buffer number may need to be specified
189         manually for best performance. A low number of router buffers risks starving the CPU
190         partitions of resources.</para>
191         <para>The default setting for router buffers will typically perform well. LNET automatically sets a
192         default value to reduce the likelihood of resource starvation</para>
193         <para>An administrator may modify router buffers using the required parameter.</para>
194         <para>There are three different kinds of router buffer parameters:</para>
195         <itemizedlist>
196                 <listitem>
197                 <para><literal>tiny_router_buffers</literal>: Zero payload buffers which are used for signals and acknowledgements.</para>
198                 </listitem>
199                 <listitem>
200                 <para><literal>small_router_buffers</literal>: 4KB payload buffers for small messages</para>
201                 </listitem>
202                 <listitem>
203                 <para><literal>large_router_buffers</literal>: 1MB maximum payload buffers. This corresponds to the recommended size of 1MB for an RPC.</para>
204                 </listitem>
205         </itemizedlist>
206         <para>These can be set using this syntax:</para>
207         <screen>options lnet large_router_buffers=8192</screen>
208         <note><para condition="&quot;l23&quot;">From Lustre 2.3 and beyond, it is possible that LNET may
209           revalidate the router buffer setting and the administrator's request do not
210           persist.</para></note>
211         <para>The purpose of the router buffers is to create a system of quotas where no single client can overwhelm the router. Router buffers are allotted to the clients.</para>
212         <para>So if increasing the router buffer parameters increases the total number of router buffers
213         available, the parameter <literal>peer_buffer_credit</literal> denotes the number of buffers
214         allotted to each client individually.</para>
215         <para>It can be set in a similar manner.</para>
216         <screen>options lnet peer_buffer_credits=256</screen>
217         </section>
218         <section><title><indexterm><primary>tuning</primary><secondary>portal round-robin</secondary></indexterm>Portal Round-Robin</title>
219         <para>Portal round-robin defines the policy LNET applies to deliver events and messages to the
220         upper layers. The upper layers are PLRPC service or LNET selftest.</para>
221         <para>If portal round-robin is disabled, LNET will deliver messages to CPTs based on a hash of the
222         source NID. Hence, all messages from a specific peer will be handled by the same CPT. This
223         can reduce data traffic between CPUs. However, for some workloads, this behavior may result
224         in poorly balancing loads across the CPU.</para>
225         <para>If portal round-robin is enabled, LNET will round-robin incoming events across all CPTs. This
226         may balance load better across the CPU but can incur a cross CPU overhead.</para>
227         <para>The current policy can be changed by an administrator with <literal>echo <replaceable>value</replaceable> &gt; /proc/sys/lnet/portal_rotor</literal>. There are four options for <literal><replaceable>value</replaceable></literal>:</para>
228     <itemizedlist>
229       <listitem>
230         <para><literal>OFF</literal></para>
231                 <para>Disable portal round-robin on all incoming requests.</para>
232       </listitem>
233       <listitem>
234         <para><literal>ON</literal></para>
235                 <para>Enable portal round-robin on all incoming requests.</para>
236       </listitem>
237       <listitem>
238         <para><literal>RR_RT</literal></para>
239                 <para>Enable portal round-robin only for routed messages.</para>
240       </listitem>
241       <listitem>
242         <para><literal>HASH_RT</literal></para>
243                 <para>Routed messages will be delivered to the upper layer by hash of source NID (instead of NID of router.) This is the default value.</para>
244       </listitem>
245     </itemizedlist>
246
247     </section>
248   </section>
249   <section xml:id="dbdoclet.libcfstuning">
250       <title><indexterm><primary>tuning</primary><secondary>libcfs</secondary></indexterm>libcfs Tuning</title>
251 <para>By default, Lustre will automatically generate CPU Partitions (CPT) based on the number of CPUs in the system. The CPT number will be 1 if the online CPU number is less than five.</para>
252         <para>The CPT number can be explicitly set on the libcfs module using <literal>cpu_npartitions=NUMBER</literal>. The value of <literal>cpu_npartitions</literal> must be an integer between 1 and the number of online CPUs.</para>
253 <tip><para>Setting CPT to 1 will disable most of the SMP Node Affinity functionality.</para></tip>
254         <section>
255                 <title>CPU Partition String Patterns</title>
256         <para>CPU Partitions can be described using string pattern notation. For example:</para>
257     <itemizedlist>
258       <listitem>
259         <para><literal>cpu_pattern="0[0,2,4,6] 1[1,3,5,7]</literal></para>
260                 <para>Create two CPTs, CPT0 contains CPU[0, 2, 4, 6]. CPT1 contains CPU[1,3,5,7].</para>
261       </listitem>
262       <listitem> <para><literal>cpu_pattern="N 0[0-3] 1[4-7]</literal></para>
263                 <para>Create two CPTs, CPT0 contains all CPUs in NUMA node[0-3], CPT1 contains all CPUs in NUMA node [4-7].</para>
264       </listitem>
265     </itemizedlist>
266         <para>The current configuration of the CPU partition can be read from <literal>/proc/sys/lnet/cpu_paratitions</literal></para>
267         </section>
268   </section>
269   <section xml:id="dbdoclet.lndtuning">
270       <title><indexterm><primary>tuning</primary><secondary>LND tuning</secondary></indexterm>LND Tuning</title>
271       <para>LND tuning allows the number of threads per CPU partition to be specified. An administrator can set the threads for both <literal>ko2iblnd</literal> and <literal>ksocklnd</literal> using the <literal>nscheds</literal> parameter. This adjusts the number of threads for each partition, not the overall number of threads on the LND.</para>
272                 <note><para>Lustre 2.3 has greatly decreased the default number of threads for <literal>ko2iblnd</literal> and <literal>ksocklnd</literal> on high-core count machines. The current default values are automatically set and are chosen to work well across a number of typical scenarios.</para></note>
273   </section>
274   <section xml:id="dbdoclet.nrstuning" condition='l24'>
275     <title><indexterm><primary>tuning</primary><secondary>Network Request Scheduler (NRS) Tuning</secondary></indexterm>Network Request Scheduler (NRS) Tuning</title>
276       <para>The Network Request Scheduler (NRS) allows the administrator to influence the order in which RPCs are handled at servers, on a per-PTLRPC service basis, by providing different policies that can be activated and tuned in order to influence the RPC ordering. The aim of this is to provide for better performance, and possibly discrete performance characteristics using future policies.</para>
277       <para>The NRS policy state of a PTLRPC service can be read and set via the <literal>{service}.nrs_policies</literal> tunable. To read a PTLRPC service's NRS policy state, run:</para>
278       <screen>lctl get_param {service}.nrs_policies</screen>
279       <para>For example, to read the NRS policy state of the ost_io service, run:</para>
280       <screen>$ lctl get_param ost.OSS.ost_io.nrs_policies
281 ost.OSS.ost_io.nrs_policies=
282
283 regular_requests:
284   - name: fifo
285     state: started
286     fallback: yes
287     queued: 0
288     active: 0
289
290   - name: crrn
291     state: stopped
292     fallback: no
293     queued: 0
294     active: 0
295
296   - name: orr
297     state: stopped
298     fallback: no
299     queued: 0
300     active: 0
301
302   - name: trr
303     state: started
304     fallback: no
305     queued: 2420
306     active: 268
307
308 high_priority_requests:
309   - name: fifo
310     state: started
311     fallback: yes
312     queued: 0
313     active: 0
314
315   - name: crrn
316     state: stopped
317     fallback: no
318     queued: 0
319     active: 0
320
321   - name: orr
322     state: stopped
323     fallback: no
324     queued: 0
325     active: 0
326
327   - name: trr
328     state: stopped
329     fallback: no
330     queued: 0
331     active: 0
332       </screen>
333       <para>NRS policy state is shown in either one or two sections, depending on the PTLRPC service being queried. The first section is named <literal>regular_requests</literal> and is available for all PTLRPC services, optionally followed by a second section which is named <literal>high_priority_requests</literal>. This is because some PTLRPC services are able to treat some types of RPCs as higher priority ones, such that they are handled by the server with higher priority compared to other, regular RPC traffic. For PTLRPC services that do not support high-priority RPCs, you will only see the <literal>regular_requests</literal> section.</para>
334       <para>There is a separate instance of each NRS policy on each PTLRPC service for handling regular and high-priority RPCs (if the service supports high-priority RPCs). For each policy instance, the following fields are shown:</para>
335       <informaltable frame="all">
336         <tgroup cols="2">
337           <colspec colname="c1" colwidth="50*"/>
338           <colspec colname="c2" colwidth="50*"/>
339           <thead>
340             <row>
341               <entry>
342                 <para><emphasis role="bold">Field</emphasis></para>
343               </entry>
344               <entry>
345                 <para><emphasis role="bold">Description</emphasis></para>
346               </entry>
347             </row>
348           </thead>
349           <tbody>
350             <row>
351               <entry>
352                 <para> <literal> name </literal></para>
353               </entry>
354               <entry>
355                 <para>The name of the policy.</para>
356               </entry>
357             </row>
358             <row>
359               <entry>
360                 <para> <literal> state </literal></para>
361               </entry>
362               <entry>
363                       <para>The state of the policy; this can be any of <literal>invalid, stopping, stopped, starting, started</literal>. A fully enabled policy is in the <literal> started</literal> state.</para>
364               </entry>
365             </row>
366             <row>
367               <entry>
368                 <para> <literal> fallback </literal></para>
369               </entry>
370               <entry>
371                       <para>Whether the policy is acting as a fallback policy or not. A fallback policy is used to handle RPCs that other enabled policies fail to handle, or do not support the handling of. The possible values are <literal>no, yes</literal>. Currently, only the FIFO policy can act as a fallback policy.</para>
372               </entry>
373             </row>
374             <row>
375               <entry>
376                 <para> <literal> queued </literal></para>
377               </entry>
378               <entry>
379                 <para>The number of RPCs that the policy has waiting to be serviced.</para>
380               </entry>
381             </row>
382             <row>
383               <entry>
384                 <para> <literal> active </literal></para>
385               </entry>
386               <entry>
387                 <para>The number of RPCs that the policy is currently handling.</para>
388               </entry>
389             </row>
390           </tbody>
391         </tgroup>
392       </informaltable>
393       <para>To enable an NRS policy on a PTLRPC service run:</para>
394       <screen>lctl set_param {service}.nrs_policies=<replaceable>policy_name</replaceable></screen>
395       <para>This will enable the policy <replaceable>policy_name</replaceable> for both regular and high-priority RPCs (if the PLRPC service supports high-priority RPCs) on the given service. For example, to enable the CRR-N NRS policy for the ldlm_cbd service, run:</para>
396       <screen>$ lctl set_param ldlm.services.ldlm_cbd.nrs_policies=crrn
397 ldlm.services.ldlm_cbd.nrs_policies=crrn
398       </screen>
399       <para>For PTLRPC services that support high-priority RPCs, you can also supply an optional <replaceable>reg|hp</replaceable> token, in order to enable an NRS policy for handling only regular or high-priority RPCs on a given PTLRPC service, by running:</para>
400       <screen>lctl set_param {service}.nrs_policies="<replaceable>policy_name</replaceable> <replaceable>reg|hp</replaceable>"</screen>
401       <para>For example, to enable the TRR policy for handling only regular, but not high-priority
402       RPCs on the <literal>ost_io</literal> service, run:</para>
403       <screen>$ lctl set_param ost.OSS.ost_io.nrs_policies="trr reg"
404 ost.OSS.ost_io.nrs_policies="trr reg"
405       </screen>
406       <note>
407         <para>When enabling an NRS policy, the policy name must be given in lower-case characters, otherwise the operation will fail with an error message.</para>
408       </note>
409     <section>
410       <title><indexterm><primary>tuning</primary><secondary>Network Request Scheduler (NRS) Tuning</secondary><tertiary>First In, First Out (FIFO) policy</tertiary></indexterm>First In, First Out (FIFO) policy</title>
411       <para>The First In, First Out (FIFO) policy handles RPCs in a service in the same order as they arrive from the LNet layer, so no special processing takes place to modify the RPC handling stream. FIFO is the default policy for all types of RPCs on all PTLRPC services, and is always enabled irrespective of the state of other policies,  so that it can be used as a backup policy, in case a more elaborate policy that has been enabled fails to handle an RPC, or does not support handling a given type of RPC.</para>
412       <para> The FIFO policy has no tunables that adjust its behaviour.</para>
413     </section>
414     <section>
415       <title><indexterm><primary>tuning</primary><secondary>Network Request Scheduler (NRS) Tuning</secondary><tertiary>Client Round-Robin over NIDs (CRR-N) policy</tertiary></indexterm>Client Round-Robin over NIDs (CRR-N) policy</title>
416       <para>The Client Round-Robin over NIDs (CRR-N) policy performs batched Round-Robin scheduling of all types of RPCs, with each batch consisting of RPCs originating from the same client node, as identified by its NID. CRR-N aims to provide for better resource utilization across the cluster, and to help shorten completion times of jobs in some cases, by distributing available bandwidth more evenly across all clients.</para>
417       <para>The CRR-N policy can be enabled on all types of PTLRPC services, and has the following tunable that can be used to adjust its behaviour:</para>
418       <itemizedlist>
419         <listitem>
420           <para><literal>{service}.nrs_crrn_quantum</literal></para>
421           <para>The <literal>{service}.nrs_crrn_quantum</literal> tunable determines the maximum allowed size of each batch of RPCs; the unit of measure is in number of RPCs. To read the maximum allowed batch size of a CRR-N policy, run:</para>
422           <screen>lctl get_param {service}.nrs_crrn_quantum</screen>
423           <para>For example, to read the maximum allowed batch size of a CRR-N policy on the ost_io service, run:</para>
424           <screen>$ lctl get_param ost.OSS.ost_io.nrs_crrn_quantum
425 ost.OSS.ost_io.nrs_crrn_quantum=reg_quantum:16
426 hp_quantum:8
427           </screen>
428           <para>You can see that there is a separate maximum allowed batch size value for regular (<literal>reg_quantum</literal>) and high-priority (<literal>hp_quantum</literal>) RPCs (if the PTLRPC service supports high-priority RPCs).</para>
429           <para>To set the maximum allowed batch size of a CRR-N policy on a given service, run:</para>
430           <screen>lctl set_param {service}.nrs_crrn_quantum=<replaceable>1-65535</replaceable></screen>
431           <para>This will set the maximum allowed batch size on a given service, for both regular and high-priority RPCs (if the PLRPC service supports high-priority RPCs), to the indicated value.</para>
432           <para>For example, to set the maximum allowed batch size on the ldlm_canceld service to 16 RPCs, run:</para>
433           <screen>$ lctl set_param ldlm.services.ldlm_canceld.nrs_crrn_quantum=16
434 ldlm.services.ldlm_canceld.nrs_crrn_quantum=16
435           </screen>
436           <para>For PTLRPC services that support high-priority RPCs, you can also specify a different maximum allowed batch size for regular and high-priority RPCs, by running:</para>
437           <screen>$ lctl set_param {service}.nrs_crrn_quantum=<replaceable>reg_quantum|hp_quantum</replaceable>:<replaceable>1-65535</replaceable>"</screen>
438           <para>For example, to set the maximum allowed batch size on the ldlm_canceld service, for high-priority RPCs to 32, run:</para>
439           <screen>$ lctl set_param ldlm.services.ldlm_canceld.nrs_crrn_quantum="hp_quantum:32"
440 ldlm.services.ldlm_canceld.nrs_crrn_quantum=hp_quantum:32
441           </screen>
442           <para>By using the last method, you can also set the maximum regular and high-priority RPC batch sizes to different values, in a single command invocation.</para>
443         </listitem>
444       </itemizedlist>
445     </section>
446     <section>
447       <title><indexterm><primary>tuning</primary><secondary>Network Request Scheduler (NRS) Tuning</secondary><tertiary>Object-based Round-Robin (ORR) policy</tertiary></indexterm>Object-based Round-Robin (ORR) policy</title>
448       <para>The Object-based Round-Robin (ORR) policy performs batched Round-Robin scheduling of bulk read write (brw) RPCs, with each batch consisting of RPCs that pertain to the same backend-filesystem object, as identified by its OST FID.</para>
449       <para>The ORR policy is only available for use on the ost_io service. The RPC batches it forms can potentially consist of mixed bulk read and bulk write RPCs. The RPCs in each batch are ordered in an ascending manner, based on either the file offsets, or the physical disk offsets of each RPC (only applicable to bulk read RPCs).</para>
450       <para>The aim of the ORR policy is to provide for increased bulk read throughput in some cases, by ordering bulk read RPCs (and potentially bulk write RPCs), and thus minimizing costly disk seek operations. Performance may also benefit from any resulting improvement in resource utilization, or by taking advantage of better locality of reference between RPCs.</para>
451       <para>The ORR policy has the following tunables that can be used to adjust its behaviour:</para>
452       <itemizedlist>
453         <listitem>
454           <para><literal>ost.OSS.ost_io.nrs_orr_quantum</literal></para>
455           <para>The <literal>ost.OSS.ost_io.nrs_orr_quantum</literal> tunable determines the maximum allowed size of each batch of RPCs; the unit of measure is in number of RPCs. To read the maximum allowed batch size of the ORR policy, run:</para>
456           <screen>$ lctl get_param ost.OSS.ost_io.nrs_orr_quantum
457 ost.OSS.ost_io.nrs_orr_quantum=reg_quantum:256
458 hp_quantum:16
459           </screen>
460           <para>You can see that there is a separate maximum allowed batch size value for regular (<literal>reg_quantum</literal>) and high-priority (<literal>hp_quantum</literal>) RPCs (if the PTLRPC service supports high-priority RPCs).</para>
461           <para>To set the maximum allowed batch size for the ORR policy, run:</para>
462           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_quantum=<replaceable>1-65535</replaceable></screen>
463           <para>This will set the maximum allowed batch size for both regular and high-priority RPCs, to the indicated value.</para>
464           <para>You can also specify a different maximum allowed batch size for regular and high-priority RPCs, by running:</para>
465           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_quantum=<replaceable>reg_quantum|hp_quantum</replaceable>:<replaceable>1-65535</replaceable></screen>
466           <para>For example, to set the maximum allowed batch size for regular RPCs to 128, run:</para>
467           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_quantum=reg_quantum:128
468 ost.OSS.ost_io.nrs_orr_quantum=reg_quantum:128
469           </screen>
470           <para>By using the last method, you can also set the maximum regular and high-priority RPC batch sizes to different values, in a single command invocation.</para>
471         </listitem>
472         <listitem>
473           <para><literal>ost.OSS.ost_io.nrs_orr_offset_type</literal></para>
474           <para>The <literal>ost.OSS.ost_io.nrs_orr_offset_type</literal> tunable determines whether the ORR policy orders RPCs within each batch based on logical file offsets or physical disk offsets. To read the offset type value for the ORR policy, run:</para>
475           <screen>$ lctl get_param ost.OSS.ost_io.nrs_orr_offset_type
476 ost.OSS.ost_io.nrs_orr_offset_type=reg_offset_type:physical
477 hp_offset_type:logical
478           </screen>
479           <para>You can see that there is a separate offset type value for regular (<literal>reg_offset_type</literal>) and high-priority (<literal>hp_offset_type</literal>) RPCs.</para>
480           <para>To set the ordering type for the ORR policy, run:</para>
481           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_offset_type=<replaceable>physical|logical</replaceable></screen>
482           <para>This will set the offset type for both regular and high-priority RPCs, to the indicated value.</para>
483           <para>You can also specify a different offset type for regular and high-priority RPCs, by running:</para>
484           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_offset_type=<replaceable>reg_offset_type|hp_offset_type</replaceable>:<replaceable>physical|logical</replaceable></screen>
485           <para>For example, to set the offset type for high-priority RPCs to physical disk offsets, run:</para>
486           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_offset_type=hp_offset_type:physical
487 ost.OSS.ost_io.nrs_orr_offset_type=hp_offset_type:physical
488           </screen>
489           <para>By using the last method, you can also set offset type for regular and high-priority RPCs to different values, in a single command invocation.</para>
490           <note><para>Irrespective of the value of this tunable, only logical offsets can, and are used for ordering bulk write RPCs.</para></note>
491         </listitem>
492         <listitem>
493           <para><literal>ost.OSS.ost_io.nrs_orr_supported</literal></para>
494           <para>The <literal>ost.OSS.ost_io.nrs_orr_supported</literal> tunable determines the type of RPCs that the ORR policy will handle. To read the types of supported RPCs by the ORR policy, run:</para>
495           <screen>$ lctl get_param ost.OSS.ost_io.nrs_orr_supported
496 ost.OSS.ost_io.nrs_orr_supported=reg_supported:reads
497 hp_supported=reads_and_writes
498           </screen>
499           <para>You can see that there is a separate supported 'RPC types' value for regular (<literal>reg_supported</literal>) and high-priority (<literal>hp_supported</literal>) RPCs.</para>
500           <para>To set the supported RPC types for the ORR policy, run:</para>
501           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_supported=<replaceable>reads|writes|reads_and_writes</replaceable></screen>
502           <para>This will set the supported RPC types for both regular and high-priority RPCs, to the indicated value.</para>
503           <para>You can also specify a different supported 'RPC types' value for regular and high-priority RPCs, by running:</para>
504           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_supported=<replaceable>reg_supported|hp_supported</replaceable>:<replaceable>reads|writes|reads_and_writes</replaceable></screen>
505           <para>For example, to set the supported RPC types to bulk read and bulk write RPCs for regular requests, run:</para>
506           <screen>$ lctl set_param ost.OSS.ost_io.nrs_orr_supported=reg_supported:reads_and_writes
507 ost.OSS.ost_io.nrs_orr_supported=reg_supported:reads_and_writes
508           </screen>
509           <para>By using the last method, you can also set the supported RPC types for regular and high-priority RPC to different values, in a single command invocation.</para>
510         </listitem>
511       </itemizedlist>
512     </section>
513     <section>
514       <title><indexterm><primary>tuning</primary><secondary>Network Request Scheduler (NRS) Tuning</secondary><tertiary>Target-based Round-Robin (TRR) policy</tertiary></indexterm>Target-based Round-Robin (TRR) policy</title>
515       <para>The Target-based Round-Robin (TRR) policy performs batched Round-Robin scheduling of brw RPCs, with each batch consisting of RPCs that pertain to the same OST, as identified by its OST index.</para>
516       <para>The TRR policy is identical to the Object-based Round-Robin (ORR) policy, apart from using the brw RPC's target OST index instead of the backend-fs object's OST FID, for determining the RPC scheduling order. The goals of TRR are effectively the same as for ORR, and it uses the following tunables to adjust its behaviour:</para>
517       <itemizedlist>
518         <listitem>
519           <para><literal>ost.OSS.ost_io.nrs_trr_quantum</literal></para>
520           <para>The purpose of this tunable is exactly the same as for the <literal>ost.OSS.ost_io.nrs_orr_quantum</literal> tunable for the ORR policy, and you can use it in exactly the same way.</para>
521         </listitem>
522         <listitem>
523           <para><literal>ost.OSS.ost_io.nrs_trr_offset_type</literal></para>
524           <para>The purpose of this tunable is exactly the same as for the <literal>ost.OSS.ost_io.nrs_orr_offset_type</literal> tunable for the ORR policy, and you can use it in exactly the same way.</para>
525         </listitem>
526         <listitem>
527           <para><literal>ost.OSS.ost_io.nrs_trr_supported</literal></para>
528           <para>The purpose of this tunable is exactly the same as for the <literal>ost.OSS.ost_io.nrs_orr_supported</literal> tunable for the ORR policy, and you can use it in exactly the sme way.</para>
529         </listitem>
530       </itemizedlist>
531     </section>
532   </section>
533   <section xml:id="dbdoclet.50438272_25884">
534       <title><indexterm><primary>tuning</primary><secondary>lockless I/O</secondary></indexterm>Lockless I/O Tunables</title>
535     <para>The lockless I/O tunable feature allows servers to ask clients to do lockless I/O (liblustre-style where the server does the locking) on contended files.</para>
536     <para>The lockless I/O patch introduces these tunables:</para>
537     <itemizedlist>
538       <listitem>
539         <para><emphasis role="bold">OST-side:</emphasis></para>
540         <screen>/proc/fs/lustre/ldlm/namespaces/filter-lustre-*
541 </screen>
542         <para><literal>contended_locks</literal> - If the number of lock conflicts in the scan of granted and waiting queues at contended_locks is exceeded, the resource is considered to be contended.</para>
543         <para><literal>contention_seconds</literal> - The resource keeps itself in a contended state as set in the parameter.</para>
544         <para><literal>max_nolock_bytes</literal> - Server-side locking set only for requests less than the blocks set in the <literal>max_nolock_bytes</literal> parameter. If this tunable is set to zero (0), it disables server-side locking for read/write requests.</para>
545       </listitem>
546       <listitem>
547         <para><emphasis role="bold">Client-side:</emphasis></para>
548         <screen>/proc/fs/lustre/llite/lustre-*</screen>
549         <para><literal>contention_seconds</literal> - <literal>llite</literal> inode remembers its contended state for the time specified in this parameter.</para>
550       </listitem>
551       <listitem>
552         <para><emphasis role="bold">Client-side statistics:</emphasis></para>
553         <para>The <literal>/proc/fs/lustre/llite/lustre-*/stats</literal> file has new rows for lockless I/O statistics.</para>
554         <para><literal>lockless_read_bytes</literal> and <literal>lockless_write_bytes</literal> - To count the total bytes read or written, the client makes its own decisions based on the request size. The client does not communicate with the server if the request size is smaller than the <literal>min_nolock_size</literal>, without acquiring locks by the client.</para>
555       </listitem>
556     </itemizedlist>
557   </section>
558   <section xml:id="dbdoclet.50438272_80545">
559     <title><indexterm><primary>tuning</primary><secondary>for small files</secondary></indexterm>Improving Lustre Performance When Working with Small Files</title>
560     <para>A Lustre environment where an application writes small file chunks from many clients to a single file will result in bad I/O performance. To improve Lustre&apos;s performance with small files:</para>
561     <itemizedlist>
562       <listitem>
563         <para>Have the application aggregate writes some amount before submitting them to Lustre. By default, Lustre enforces POSIX coherency semantics, so it results in lock ping-pong between client nodes if they are all writing to the same file at one time.</para>
564       </listitem>
565       <listitem>
566         <para>Have the application do 4kB <literal>O_DIRECT</literal> sized I/O to the file and disable locking on the output file. This avoids partial-page IO submissions and, by disabling locking, you avoid contention between clients.</para>
567       </listitem>
568       <listitem>
569         <para>Have the application write contiguous data.</para>
570       </listitem>
571       <listitem>
572         <para>Add more disks or use SSD disks for the OSTs. This dramatically improves the IOPS rate. Consider creating larger OSTs rather than many smaller OSTs due to less overhead (journal, connections, etc).</para>
573       </listitem>
574       <listitem>
575         <para>Use RAID-1+0 OSTs instead of RAID-5/6. There is RAID parity overhead for writing small chunks of data to disk.</para>
576       </listitem>
577     </itemizedlist>
578   </section>
579   <section xml:id="dbdoclet.50438272_45406">
580     <title><indexterm><primary>tuning</primary><secondary>write performance</secondary></indexterm>Understanding Why Write Performance is Better Than Read Performance</title>
581     <para>Typically, the performance of write operations on a Lustre cluster is better than read operations. When doing writes, all clients are sending write RPCs asynchronously. The RPCs are allocated, and written to disk in the order they arrive. In many cases, this allows the back-end storage to aggregate writes efficiently.</para>
582     <para>In the case of read operations, the reads from clients may come in a different order and need a lot of seeking to get read from the disk. This noticeably hampers the read throughput.</para>
583     <para>Currently, there is no readahead on the OSTs themselves, though the clients do readahead. If there are lots of clients doing reads it would not be possible to do any readahead in any case because of memory consumption (consider that even a single RPC (1 MB) readahead for 1000 clients would consume 1 GB of RAM).</para>
584     <para>For file systems that use socklnd (TCP, Ethernet) as interconnect, there is also additional CPU overhead because the client cannot receive data without copying it from the network buffers. In the write case, the client CAN send data without the additional data copy. This means that the client is more likely to become CPU-bound during reads than writes.</para>
585   </section>
586 </chapter>