Whamcloud - gitweb
LUDOC-394 manual: Remove extra 'held' word
[doc/manual.git] / LustreTuning.xml
1 <?xml version='1.0' encoding='utf-8'?>
2 <chapter xmlns="http://docbook.org/ns/docbook"
3  xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en-US"
4  xml:id="lustretuning">
5   <title xml:id="lustretuning.title">Tuning a Lustre File System</title>
6   <para>This chapter contains information about tuning a Lustre file system for
7   better performance.</para>
8   <note>
9     <para>Many options in the Lustre software are set by means of kernel module
10     parameters. These parameters are contained in the 
11     <literal>/etc/modprobe.d/lustre.conf</literal> file.</para>
12   </note>
13   <section xml:id="tuning_optimizing_service_threads">
14     <title>
15     <indexterm>
16       <primary>tuning</primary>
17     </indexterm>
18     <indexterm>
19       <primary>tuning</primary>
20       <secondary>service threads</secondary>
21     </indexterm>Optimizing the Number of Service Threads</title>
22     <para>An OSS can have a minimum of two service threads and a maximum of 512
23     service threads. The number of service threads is a function of how much
24     RAM and how many CPUs are on each OSS node (1 thread / 128MB * num_cpus).
25     If the load on the OSS node is high, new service threads will be started in
26     order to process more requests concurrently, up to 4x the initial number of
27     threads (subject to the maximum of 512). For a 2GB 2-CPU system, the
28     default thread count is 32 and the maximum thread count is 128.</para>
29     <para>Increasing the size of the thread pool may help when:</para>
30     <itemizedlist>
31       <listitem>
32         <para>Several OSTs are exported from a single OSS</para>
33       </listitem>
34       <listitem>
35         <para>Back-end storage is running synchronously</para>
36       </listitem>
37       <listitem>
38         <para>I/O completions take excessive time due to slow storage</para>
39       </listitem>
40     </itemizedlist>
41     <para>Decreasing the size of the thread pool may help if:</para>
42     <itemizedlist>
43       <listitem>
44         <para>Clients are overwhelming the storage capacity</para>
45       </listitem>
46       <listitem>
47         <para>There are lots of "slow I/O" or similar messages</para>
48       </listitem>
49     </itemizedlist>
50     <para>Increasing the number of I/O threads allows the kernel and storage to
51     aggregate many writes together for more efficient disk I/O. The OSS thread
52     pool is shared--each thread allocates approximately 1.5 MB (maximum RPC
53     size + 0.5 MB) for internal I/O buffers.</para>
54     <para>It is very important to consider memory consumption when increasing
55     the thread pool size. Drives are only able to sustain a certain amount of
56     parallel I/O activity before performance is degraded, due to the high
57     number of seeks and the OST threads just waiting for I/O. In this
58     situation, it may be advisable to decrease the load by decreasing the
59     number of OST threads.</para>
60     <para>Determining the optimum number of OSS threads is a process of trial
61     and error, and varies for each particular configuration. Variables include
62     the number of OSTs on each OSS, number and speed of disks, RAID
63     configuration, and available RAM. You may want to start with a number of
64     OST threads equal to the number of actual disk spindles on the node. If you
65     use RAID, subtract any dead spindles not used for actual data (e.g., 1 of N
66     of spindles for RAID5, 2 of N spindles for RAID6), and monitor the
67     performance of clients during usual workloads. If performance is degraded,
68     increase the thread count and see how that works until performance is
69     degraded again or you reach satisfactory performance.</para>
70     <note>
71       <para>If there are too many threads, the latency for individual I/O
72       requests can become very high and should be avoided. Set the desired
73       maximum thread count permanently using the method described above.</para>
74     </note>
75     <section>
76       <title>
77       <indexterm>
78         <primary>tuning</primary>
79         <secondary>OSS threads</secondary>
80       </indexterm>Specifying the OSS Service Thread Count</title>
81       <para>The 
82       <literal>oss_num_threads</literal> parameter enables the number of OST
83       service threads to be specified at module load time on the OSS
84       nodes:</para>
85       <screen>
86 options ost oss_num_threads={N}
87 </screen>
88       <para>After startup, the minimum and maximum number of OSS thread counts
89       can be set via the 
90       <literal>{service}.thread_{min,max,started}</literal> tunable. To change
91       the tunable at runtime, run:</para>
92       <para>
93         <screen>
94 lctl {get,set}_param {service}.thread_{min,max,started}
95 </screen>
96       </para>
97       <para>
98       This works in a similar fashion to 
99       binding of threads on MDS. MDS thread tuning is covered in 
100       <xref linkend="mdsbinding" />.</para>
101       <itemizedlist>
102         <listitem>
103           <para>
104           <literal>oss_cpts=[EXPRESSION]</literal> binds the default OSS service
105           on CPTs defined by 
106           <literal>[EXPRESSION]</literal>.</para>
107         </listitem>
108         <listitem>
109           <para>
110           <literal>oss_io_cpts=[EXPRESSION]</literal> binds the IO OSS service
111           on CPTs defined by 
112           <literal>[EXPRESSION]</literal>.</para>
113         </listitem>
114       </itemizedlist>
115       <para>For further details, see 
116       <xref linkend="tuning_setting_thread_count" />.</para>
117     </section>
118     <section xml:id="mdstuning">
119       <title>
120       <indexterm>
121         <primary>tuning</primary>
122         <secondary>MDS threads</secondary>
123       </indexterm>Specifying the MDS Service Thread Count</title>
124       <para>The 
125       <literal>mds_num_threads</literal> parameter enables the number of MDS
126       service threads to be specified at module load time on the MDS
127       node:</para>
128       <screen>options mds mds_num_threads={N}</screen>
129       <para>After startup, the minimum and maximum number of MDS thread counts
130       can be set via the 
131       <literal>{service}.thread_{min,max,started}</literal> tunable. To change
132       the tunable at runtime, run:</para>
133       <para>
134         <screen>
135 lctl {get,set}_param {service}.thread_{min,max,started}
136 </screen>
137       </para>
138       <para>For details, see 
139       <xref linkend="tuning_setting_thread_count" />.</para>
140       <para>The number of MDS service threads started depends on system size
141       and the load on the server, and has a default maximum of 64. The
142       maximum potential number of threads (<literal>MDS_MAX_THREADS</literal>)
143       is 1024.</para>
144       <note>
145         <para>The OSS and MDS start two threads per service per CPT at mount
146         time, and dynamically increase the number of running service threads in
147         response to server load. Setting the <literal>*_num_threads</literal>
148         module parameter starts the specified number of threads for that
149         service immediately and disables automatic thread creation behavior.
150         </para>
151       </note>
152       <para>Parameters are available to provide administrators control
153         over the number of service threads.</para>
154       <itemizedlist>
155         <listitem>
156           <para>
157           <literal>mds_rdpg_num_threads</literal> controls the number of threads
158           in providing the read page service. The read page service handles
159           file close and readdir operations.</para>
160         </listitem>
161       </itemizedlist>
162     </section>
163   </section>
164   <section xml:id="mdsbinding">
165     <title>
166     <indexterm>
167       <primary>tuning</primary>
168       <secondary>MDS binding</secondary>
169     </indexterm>Binding MDS Service Thread to CPU Partitions</title>
170     <para>With the Node Affinity (<xref linkend="nodeaffdef" />) feature,
171     MDS threads can be bound to particular CPU partitions (CPTs) to improve CPU
172     cache usage and memory locality.  Default values for CPT counts and CPU core
173     bindings are selected automatically to provide good overall performance for
174     a given CPU count. However, an administrator can deviate from these setting
175     if they choose.  For details on specifying the mapping of CPU cores to
176     CPTs see <xref linkend="libcfstuning"/>.
177     </para>
178     <itemizedlist>
179       <listitem>
180         <para>
181         <literal>mds_num_cpts=[EXPRESSION]</literal> binds the default MDS
182         service threads to CPTs defined by 
183         <literal>EXPRESSION</literal>. For example 
184         <literal>mds_num_cpts=[0-3]</literal> will bind the MDS service threads
185         to 
186         <literal>CPT[0,1,2,3]</literal>.</para>
187       </listitem>
188       <listitem>
189         <para>
190         <literal>mds_rdpg_num_cpts=[EXPRESSION]</literal> binds the read page
191         service threads to CPTs defined by 
192         <literal>EXPRESSION</literal>. The read page service handles file close
193         and readdir requests. For example 
194         <literal>mds_rdpg_num_cpts=[4]</literal> will bind the read page threads
195         to 
196         <literal>CPT4</literal>.</para>
197       </listitem>
198     </itemizedlist>
199     <para>Parameters must be set before module load in the file 
200     <literal>/etc/modprobe.d/lustre.conf</literal>. For example:
201     <example><title>lustre.conf</title>
202     <screen>options lnet networks=tcp0(eth0)
203 options mdt mds_num_cpts=[0]</screen>
204     </example>
205     </para>
206   </section>
207   <section xml:id="tuning_lnet_params">
208     <title>
209     <indexterm>
210       <primary>LNet</primary>
211       <secondary>tuning</secondary>
212     </indexterm>
213     <indexterm>
214       <primary>tuning</primary>
215       <secondary>LNet</secondary>
216     </indexterm>Tuning LNet Parameters</title>
217     <para>This section describes LNet tunables, the use of which may be
218     necessary on some systems to improve performance. To test the performance
219     of your Lustre network, see 
220     <xref linkend='lnetselftest' />.</para>
221     <section remap="h3">
222       <title>Transmit and Receive Buffer Size</title>
223       <para>The kernel allocates buffers for sending and receiving messages on
224       a network.</para>
225       <para>
226       <literal>ksocklnd</literal> has separate parameters for the transmit and
227       receive buffers.</para>
228       <screen>
229 options ksocklnd tx_buffer_size=0 rx_buffer_size=0
230 </screen>
231       <para>If these parameters are left at the default value (0), the system
232       automatically tunes the transmit and receive buffer size. In almost every
233       case, this default produces the best performance. Do not attempt to tune
234       these parameters unless you are a network expert.</para>
235     </section>
236     <section remap="h3">
237       <title>Hardware Interrupts (
238       <literal>enable_irq_affinity</literal>)</title>
239       <para>The hardware interrupts that are generated by network adapters may
240       be handled by any CPU in the system. In some cases, we would like network
241       traffic to remain local to a single CPU to help keep the processor cache
242       warm and minimize the impact of context switches. This is helpful when an
243       SMP system has more than one network interface and ideal when the number
244       of interfaces equals the number of CPUs. To enable the 
245       <literal>enable_irq_affinity</literal> parameter, enter:</para>
246       <screen>
247 options ksocklnd enable_irq_affinity=1
248 </screen>
249       <para>In other cases, if you have an SMP platform with a single fast
250       interface such as 10 Gb Ethernet and more than two CPUs, you may see
251       performance improve by turning this parameter off.</para>
252       <screen>
253 options ksocklnd enable_irq_affinity=0
254 </screen>
255       <para>By default, this parameter is off. As always, you should test the
256       performance to compare the impact of changing this parameter.</para>
257     </section>
258     <section>
259       <title>
260       <indexterm>
261         <primary>tuning</primary>
262         <secondary>Network interface binding</secondary>
263       </indexterm>Binding Network Interface Against CPU Partitions</title>
264       <para>Lustre allows enhanced network interface control. This means that
265       an administrator can bind an interface to one or more CPU partitions.
266       Bindings are specified as options to the LNet modules. For more
267       information on specifying module options, see 
268       <xref linkend="tuning_lnet_mod_params" /></para>
269       <para>For example, 
270       <literal>o2ib0(ib0)[0,1]</literal> will ensure that all messages for 
271       <literal>o2ib0</literal> will be handled by LND threads executing on 
272       <literal>CPT0</literal> and 
273       <literal>CPT1</literal>. An additional example might be: 
274       <literal>tcp1(eth0)[0]</literal>. Messages for 
275       <literal>tcp1</literal> are handled by threads on 
276       <literal>CPT0</literal>.</para>
277     </section>
278     <section>
279       <title>
280       <indexterm>
281         <primary>tuning</primary>
282         <secondary>Network interface credits</secondary>
283       </indexterm>Network Interface Credits</title>
284       <para>Network interface (NI) credits are shared across all CPU partitions
285       (CPT). For example, if a machine has four CPTs and the number of NI
286       credits is 512, then each partition has 128 credits. If a large number of
287       CPTs exist on the system, LNet checks and validates the NI credits for
288       each CPT to ensure each CPT has a workable number of credits. For
289       example, if a machine has 16 CPTs and the number of NI credits is 256,
290       then each partition only has 16 credits. 16 NI credits is low and could
291       negatively impact performance. As a result, LNet automatically adjusts
292       the credits to 8*
293       <literal>peer_credits</literal>(
294       <literal>peer_credits</literal> is 8 by default), so each partition has 64
295       credits.</para>
296       <para>Increasing the number of 
297       <literal>credits</literal>/
298       <literal>peer_credits</literal> can improve the performance of high
299       latency networks (at the cost of consuming more memory) by enabling LNet
300       to send more inflight messages to a specific network/peer and keep the
301       pipeline saturated.</para>
302       <para>An administrator can modify the NI credit count using 
303       <literal>ksoclnd</literal> or 
304       <literal>ko2iblnd</literal>. In the example below, 256 credits are
305       applied to TCP connections.</para>
306       <screen>
307 ksocklnd credits=256
308 </screen>
309       <para>Applying 256 credits to IB connections can be achieved with:</para>
310       <screen>
311 ko2iblnd credits=256
312 </screen>
313       <note>
314         <para>LNet may revalidate the NI credits, so the administrator's
315         request may not persist.</para>
316       </note>
317     </section>
318     <section>
319       <title>
320       <indexterm>
321         <primary>tuning</primary>
322         <secondary>router buffers</secondary>
323       </indexterm>Router Buffers</title>
324       <para>When a node is set up as an LNet router, three pools of buffers are
325       allocated: tiny, small and large. These pools are allocated per CPU
326       partition and are used to buffer messages that arrive at the router to be
327       forwarded to the next hop. The three different buffer sizes accommodate
328       different size messages.</para>
329       <para>If a message arrives that can fit in a tiny buffer then a tiny
330       buffer is used, if a message doesn’t fit in a tiny buffer, but fits in a
331       small buffer, then a small buffer is used. Finally if a message does not
332       fit in either a tiny buffer or a small buffer, a large buffer is
333       used.</para>
334       <para>Router buffers are shared by all CPU partitions. For a machine with
335       a large number of CPTs, the router buffer number may need to be specified
336       manually for best performance. A low number of router buffers risks
337       starving the CPU partitions of resources.</para>
338       <itemizedlist>
339         <listitem>
340           <para>
341           <literal>tiny_router_buffers</literal>: Zero payload buffers used for
342           signals and acknowledgements.</para>
343         </listitem>
344         <listitem>
345           <para>
346           <literal>small_router_buffers</literal>: 4 KB payload buffers for
347           small messages</para>
348         </listitem>
349         <listitem>
350           <para>
351           <literal>large_router_buffers</literal>: 1 MB maximum payload
352           buffers, corresponding to the recommended RPC size of 1 MB.</para>
353         </listitem>
354       </itemizedlist>
355       <para>The default setting for router buffers typically results in
356       acceptable performance. LNet automatically sets a default value to reduce
357       the likelihood of resource starvation. The size of a router buffer can be
358       modified as shown in the example below. In this example, the size of the
359       large buffer is modified using the 
360       <literal>large_router_buffers</literal> parameter.</para>
361       <screen>
362 lnet large_router_buffers=8192
363 </screen>
364       <note>
365         <para>LNet may revalidate the router buffer setting, so the
366         administrator's request may not persist.</para>
367       </note>
368     </section>
369     <section>
370       <title>
371       <indexterm>
372         <primary>tuning</primary>
373         <secondary>portal round-robin</secondary>
374       </indexterm>Portal Round-Robin</title>
375       <para>Portal round-robin defines the policy LNet applies to deliver
376       events and messages to the upper layers. The upper layers are PLRPC
377       service or LNet selftest.</para>
378       <para>If portal round-robin is disabled, LNet will deliver messages to
379       CPTs based on a hash of the source NID. Hence, all messages from a
380       specific peer will be handled by the same CPT. This can reduce data
381       traffic between CPUs. However, for some workloads, this behavior may
382       result in poorly balancing loads across the CPU.</para>
383       <para>If portal round-robin is enabled, LNet will round-robin incoming
384       events across all CPTs. This may balance load better across the CPU but
385       can incur a cross CPU overhead.</para>
386       <para>The current policy can be changed by an administrator with 
387       <literal>lctl set_param portal_rotor=value</literal>. 
388       There are four options for 
389       <literal>
390         <replaceable>value</replaceable>
391       </literal>:</para>
392       <itemizedlist>
393         <listitem>
394           <para>
395             <literal>OFF</literal>
396           </para>
397           <para>Disable portal round-robin on all incoming requests.</para>
398         </listitem>
399         <listitem>
400           <para>
401             <literal>ON</literal>
402           </para>
403           <para>Enable portal round-robin on all incoming requests.</para>
404         </listitem>
405         <listitem>
406           <para>
407             <literal>RR_RT</literal>
408           </para>
409           <para>Enable portal round-robin only for routed messages.</para>
410         </listitem>
411         <listitem>
412           <para>
413             <literal>HASH_RT</literal>
414           </para>
415           <para>Routed messages will be delivered to the upper layer by hash of
416           source NID (instead of NID of router.) This is the default
417           value.</para>
418         </listitem>
419       </itemizedlist>
420     </section>
421     <section>
422       <title>LNet Peer Health</title>
423       <para>Two options are available to help determine peer health:
424       <itemizedlist>
425         <listitem>
426           <para>
427           <literal>peer_timeout</literal>- The timeout (in seconds) before an
428           aliveness query is sent to a peer. For example, if 
429           <literal>peer_timeout</literal> is set to 
430           <literal>180sec</literal>, an aliveness query is sent to the peer
431           every 180 seconds. This feature only takes effect if the node is
432           configured as an LNet router.</para>
433           <para>In a routed environment, the 
434           <literal>peer_timeout</literal> feature should always be on (set to a
435           value in seconds) on routers. If the router checker has been enabled,
436           the feature should be turned off by setting it to 0 on clients and
437           servers.</para>
438           <para>For a non-routed scenario, enabling the 
439           <literal>peer_timeout</literal> option provides health information
440           such as whether a peer is alive or not. For example, a client is able
441           to determine if an MGS or OST is up when it sends it a message. If a
442           response is received, the peer is alive; otherwise a timeout occurs
443           when the request is made.</para>
444           <para>In general, 
445           <literal>peer_timeout</literal> should be set to no less than the LND
446           timeout setting. For more information about LND timeouts, see 
447           <xref xmlns:xlink="http://www.w3.org/1999/xlink"
448           linkend="section_c24_nt5_dl" />.</para>
449           <para>When the 
450           <literal>o2iblnd</literal>(IB) driver is used, 
451           <literal>peer_timeout</literal> should be at least twice the value of
452           the 
453           <literal>ko2iblnd</literal> keepalive option. for more information
454           about keepalive options, see 
455           <xref xmlns:xlink="http://www.w3.org/1999/xlink"
456           linkend="section_ngq_qhy_zl" />.</para>
457         </listitem>
458         <listitem>
459           <para>
460           <literal>avoid_asym_router_failure</literal>– When set to 1, the
461           router checker running on the client or a server periodically pings
462           all the routers corresponding to the NIDs identified in the routes
463           parameter setting on the node to determine the status of each router
464           interface. The default setting is 1. (For more information about the
465           LNet routes parameter, see 
466           <xref xmlns:xlink="http://www.w3.org/1999/xlink"
467           linkend="lnet_module_routes" /></para>
468           <para>A router is considered down if any of its NIDs are down. For
469           example, router X has three NIDs: 
470           <literal>Xnid1</literal>, 
471           <literal>Xnid2</literal>, and 
472           <literal>Xnid3</literal>. A client is connected to the router via 
473           <literal>Xnid1</literal>. The client has router checker enabled. The
474           router checker periodically sends a ping to the router via 
475           <literal>Xnid1</literal>. The router responds to the ping with the
476           status of each of its NIDs. In this case, it responds with 
477           <literal>Xnid1=up</literal>, 
478           <literal>Xnid2=up</literal>, 
479           <literal>Xnid3=down</literal>. If 
480           <literal>avoid_asym_router_failure==1</literal>, the router is
481           considered down if any of its NIDs are down, so router X is
482           considered down and will not be used for routing messages. If 
483           <literal>avoid_asym_router_failure==0</literal>, router X will
484           continue to be used for routing messages.</para>
485         </listitem>
486       </itemizedlist></para>
487       <para>The following router checker parameters must be set to the maximum
488       value of the corresponding setting for this option on any client or
489       server:
490       <itemizedlist>
491         <listitem>
492           <para>
493             <literal>dead_router_check_interval</literal>
494           </para>
495         </listitem>
496         <listitem>
497           <para>
498             <literal>live_router_check_interval</literal>
499           </para>
500         </listitem>
501         <listitem>
502           <para>
503             <literal>router_ping_timeout</literal>
504           </para>
505         </listitem>
506       </itemizedlist></para>
507       <para>For example, the 
508       <literal>dead_router_check_interval</literal> parameter on any router must
509       be MAX.</para>
510     </section>
511   </section>
512   <section xml:id="libcfstuning">
513     <title>
514     <indexterm>
515       <primary>tuning</primary>
516       <secondary>libcfs</secondary>
517     </indexterm>libcfs Tuning</title>
518     <para>Lustre allows binding service threads via CPU Partition Tables
519       (CPTs). This allows the system administrator to fine-tune on which CPU
520       cores the Lustre service threads are run, for both OSS and MDS services,
521       as well as on the client.
522     </para>
523     <para>CPTs are useful to reserve some cores on the OSS or MDS nodes for
524     system functions such as system monitoring, HA heartbeat, or similar
525     tasks.  On the client it may be useful to restrict Lustre RPC service
526     threads to a small subset of cores so that they do not interfere with
527     computation, or because these cores are directly attached to the network
528     interfaces.
529     </para>
530     <para>By default, the Lustre software will automatically generate CPU
531     partitions (CPT) based on the number of CPUs in the system.
532     The CPT count can be explicitly set on the libcfs module using 
533     <literal>cpu_npartitions=<replaceable>NUMBER</replaceable></literal>.
534     The value of <literal>cpu_npartitions</literal> must be an integer between
535     1 and the number of online CPUs.
536     </para>
537     <para condition='l29'>In Lustre 2.9 and later the default is to use
538     one CPT per NUMA node.  In earlier versions of Lustre, by default there
539     was a single CPT if the online CPU core count was four or fewer, and
540     additional CPTs would be created depending on the number of CPU cores,
541     typically with 4-8 cores per CPT.
542     </para>
543     <tip>
544       <para>Setting <literal>cpu_npartitions=1</literal> will disable most
545       of the SMP Node Affinity functionality.</para>
546     </tip>
547     <section>
548       <title>CPU Partition String Patterns</title>
549       <para>CPU partitions can be described using string pattern notation.
550       If <literal>cpu_pattern=N</literal> is used, then there will be one
551       CPT for each NUMA node in the system, with each CPT mapping all of
552       the CPU cores for that NUMA node.
553       </para>
554       <para>It is also possible to explicitly specify the mapping between
555       CPU cores and CPTs, for example:</para>
556       <itemizedlist>
557         <listitem>
558           <para>
559             <literal>cpu_pattern="0[2,4,6] 1[3,5,7]</literal>
560           </para>
561           <para>Create two CPTs, CPT0 contains cores 2, 4, and 6, while CPT1
562           contains cores 3, 5, 7.  CPU cores 0 and 1 will not be used by Lustre
563           service threads, and could be used for node services such as
564           system monitoring, HA heartbeat threads, etc.  The binding of
565           non-Lustre services to those CPU cores may be done in userspace
566           using <literal>numactl(8)</literal> or other application-specific
567           methods, but is beyond the scope of this document.</para>
568         </listitem>
569         <listitem>
570           <para>
571             <literal>cpu_pattern="N 0[0-3] 1[4-7]</literal>
572           </para>
573           <para>Create two CPTs, with CPT0 containing all CPUs in NUMA
574           node[0-3], while CPT1 contains all CPUs in NUMA node [4-7].</para>
575         </listitem>
576       </itemizedlist>
577       <para>The current configuration of the CPU partition can be read via 
578       <literal>lctl get_parm cpu_partition_table</literal>.  For example,
579       a simple 4-core system has a single CPT with all four CPU cores:
580       <screen>$ lctl get_param cpu_partition_table
581 cpu_partition_table=0   : 0 1 2 3</screen>
582       while a larger NUMA system with four 12-core CPUs may have four CPTs:
583       <screen>$ lctl get_param cpu_partition_table
584 cpu_partition_table=
585 0       : 0 1 2 3 4 5 6 7 8 9 10 11
586 1       : 12 13 14 15 16 17 18 19 20 21 22 23
587 2       : 24 25 26 27 28 29 30 31 32 33 34 35
588 3       : 36 37 38 39 40 41 42 43 44 45 46 47
589 </screen>
590       </para>
591     </section>
592   </section>
593   <section xml:id="lndtuning">
594     <title>
595     <indexterm>
596       <primary>tuning</primary>
597       <secondary>LND tuning</secondary>
598     </indexterm>LND Tuning</title>
599     <para>LND tuning allows the number of threads per CPU partition to be
600     specified. An administrator can set the threads for both 
601     <literal>ko2iblnd</literal> and 
602     <literal>ksocklnd</literal> using the 
603     <literal>nscheds</literal> parameter. This adjusts the number of threads for
604     each partition, not the overall number of threads on the LND.</para>
605     <note>
606       <para>The default number of threads for 
607       <literal>ko2iblnd</literal> and 
608       <literal>ksocklnd</literal> are automatically set and are chosen to
609       work well across a number of typical scenarios, for systems with both
610       high and low core counts.</para>
611     </note>
612     <section>
613         <title>ko2iblnd Tuning</title>
614         <para>The following table outlines the ko2iblnd module parameters to be used
615     for tuning:</para>
616         <informaltable frame="all">
617           <tgroup cols="3">
618             <colspec colname="c1" colwidth="50*" />
619             <colspec colname="c2" colwidth="50*" />
620             <colspec colname="c3" colwidth="50*" />
621             <thead>
622               <row>
623                 <entry>
624                   <para>
625                     <emphasis role="bold">Module Parameter</emphasis>
626                   </para>
627                 </entry>
628                 <entry>
629                   <para>
630                     <emphasis role="bold">Default Value</emphasis>
631                   </para>
632                 </entry>
633                 <entry>
634                   <para>
635                     <emphasis role="bold">Description</emphasis>
636                   </para>
637                 </entry>
638               </row>
639             </thead>
640             <tbody>
641               <row>
642                 <entry>
643                   <para>
644                     <literal>service</literal>
645                   </para>
646                 </entry>
647                 <entry>
648                   <para>
649                     <literal>987</literal>
650                   </para>
651                 </entry>
652                 <entry>
653                   <para>Service number (within RDMA_PS_TCP).</para>
654                 </entry>
655               </row>
656               <row>
657                 <entry>
658                   <para>
659                     <literal>cksum</literal>
660                   </para>
661                 </entry>
662                 <entry>
663                   <para>
664                     <literal>0</literal>
665                   </para>
666                 </entry>
667                 <entry>
668                   <para>Set non-zero to enable message (not RDMA) checksums.</para>
669                 </entry>
670               </row>
671               <row>
672                 <entry>
673                   <para>
674                     <literal>timeout</literal>
675                   </para>
676                 </entry>
677                 <entry>
678                 <para>
679                   <literal>50</literal>
680                 </para>
681               </entry>
682                 <entry>
683                   <para>Timeout in seconds.</para>
684                 </entry>
685               </row>
686               <row>
687                 <entry>
688                   <para>
689                     <literal>nscheds</literal>
690                   </para>
691                 </entry>
692                 <entry>
693                   <para>
694                     <literal>0</literal>
695                   </para>
696                 </entry>
697                 <entry>
698                   <para>Number of threads in each scheduler pool (per CPT).  Value of
699           zero means we derive the number from the number of cores.</para>
700                 </entry>
701               </row>
702               <row>
703                 <entry>
704                   <para>
705                     <literal>conns_per_peer</literal>
706                   </para>
707                 </entry>
708                 <entry>
709                   <para>
710                     <literal>4 (OmniPath), 1 (Everything else)</literal>
711                   </para>
712                 </entry>
713                 <entry>
714                   <para>Introduced in 2.10. Number of connections to each peer. Messages
715           are sent round-robin over the connection pool.  Provides significant
716           improvement with OmniPath.</para>
717                 </entry>
718               </row>
719               <row>
720                 <entry>
721                   <para>
722                     <literal>ntx</literal>
723                   </para>
724                 </entry>
725                 <entry>
726                   <para>
727                     <literal>512</literal>
728                   </para>
729                 </entry>
730                 <entry>
731                   <para>Number of message descriptors allocated for each pool at
732           startup. Grows at runtime. Shared by all CPTs.</para>
733                 </entry>
734               </row>
735               <row>
736                 <entry>
737                   <para>
738                     <literal>credits</literal>
739                   </para>
740                 </entry>
741                 <entry>
742                   <para>
743                     <literal>256</literal>
744                   </para>
745                 </entry>
746                 <entry>
747                   <para>Number of concurrent sends on network.</para>
748                 </entry>
749               </row>
750               <row>
751                 <entry>
752                   <para>
753                     <literal>peer_credits</literal>
754                   </para>
755                 </entry>
756                 <entry>
757                   <para>
758                     <literal>8</literal>
759                   </para>
760                 </entry>
761                 <entry>
762                   <para>Number of concurrent sends to 1 peer. Related/limited by IB
763           queue size.</para>
764                 </entry>
765               </row>
766               <row>
767                 <entry>
768                   <para>
769                     <literal>peer_credits_hiw</literal>
770                   </para>
771                 </entry>
772                 <entry>
773                   <para>
774                     <literal>0</literal>
775                   </para>
776                 </entry>
777                 <entry>
778                   <para>When eagerly to return credits.</para>
779                 </entry>
780               </row>
781               <row>
782                 <entry>
783                   <para>
784                     <literal>peer_buffer_credits</literal>
785                   </para>
786                 </entry>
787                 <entry>
788                   <para>
789                     <literal>0</literal>
790                   </para>
791                 </entry>
792                 <entry>
793                   <para>Number per-peer router buffer credits.</para>
794                 </entry>
795               </row>
796               <row>
797                 <entry>
798                   <para>
799                     <literal>peer_timeout</literal>
800                   </para>
801                 </entry>
802                 <entry>
803                   <para>
804                     <literal>180</literal>
805                   </para>
806                 </entry>
807                 <entry>
808                   <para>Seconds without aliveness news to declare peer dead (less than
809           or equal to 0 to disable).</para>
810                 </entry>
811               </row>
812               <row>
813                 <entry>
814                   <para>
815                     <literal>ipif_name</literal>
816                   </para>
817                 </entry>
818                 <entry>
819                   <para>
820                     <literal>ib0</literal>
821                   </para>
822                 </entry>
823                 <entry>
824                   <para>IPoIB interface name.</para>
825                 </entry>
826               </row>
827               <row>
828                 <entry>
829                   <para>
830                     <literal>retry_count</literal>
831                   </para>
832                 </entry>
833                 <entry>
834                   <para>
835                     <literal>5</literal>
836                   </para>
837                 </entry>
838                 <entry>
839                   <para>Retransmissions when no ACK received.</para>
840                 </entry>
841               </row>
842               <row>
843                 <entry>
844                   <para>
845                     <literal>rnr_retry_count</literal>
846                   </para>
847                 </entry>
848                 <entry>
849                   <para>
850                     <literal>6</literal>
851                   </para>
852                 </entry>
853                 <entry>
854                   <para>RNR retransmissions.</para>
855                 </entry>
856               </row>
857               <row>
858                 <entry>
859                   <para>
860                     <literal>keepalive</literal>
861                   </para>
862                 </entry>
863                 <entry>
864                   <para>
865                     <literal>100</literal>
866                   </para>
867                 </entry>
868                 <entry>
869                   <para>Idle time in seconds before sending a keepalive.</para>
870                 </entry>
871               </row>
872               <row>
873                 <entry>
874                   <para>
875                     <literal>ib_mtu</literal>
876                   </para>
877                 </entry>
878                 <entry>
879                   <para>
880                     <literal>0</literal>
881                   </para>
882                 </entry>
883                 <entry>
884                   <para>IB MTU 256/512/1024/2048/4096.</para>
885                 </entry>
886               </row>
887               <row>
888                 <entry>
889                   <para>
890                     <literal>concurrent_sends</literal>
891                   </para>
892                 </entry>
893                 <entry>
894                   <para>
895                     <literal>0</literal>
896                   </para>
897                 </entry>
898                 <entry>
899                   <para>Send work-queue sizing. If zero, derived from
900           <literal>map_on_demand</literal> and <literal>peer_credits</literal>.
901           </para>
902                 </entry>
903               </row>
904               <row>
905                 <entry>
906                   <para>
907                     <literal>map_on_demand</literal>
908                   </para>
909                 </entry>
910                 <entry>
911                   <para>
912             <literal>0 (pre-4.8 Linux) 1 (4.8 Linux onward) 32 (OmniPath)</literal>
913                   </para>
914                 </entry>
915                 <entry>
916                   <para>Number of fragments reserved for connection.  If zero, use
917           global memory region (found to be security issue).  If non-zero, use
918           FMR or FastReg for memory registration.  Value needs to agree between
919           both peers of connection.</para>
920                 </entry>
921               </row>
922               <row>
923                 <entry>
924                   <para>
925                     <literal>fmr_pool_size</literal>
926                   </para>
927                 </entry>
928                 <entry>
929                   <para>
930                     <literal>512</literal>
931                   </para>
932                 </entry>
933                 <entry>
934                   <para>Size of fmr pool on each CPT (>= ntx / 4).  Grows at runtime.
935           </para>
936                 </entry>
937               </row>
938               <row>
939                 <entry>
940                   <para>
941                     <literal>fmr_flush_trigger</literal>
942                   </para>
943                 </entry>
944                 <entry>
945                   <para>
946                     <literal>384</literal>
947                   </para>
948                 </entry>
949                 <entry>
950                   <para>Number dirty FMRs that triggers pool flush.</para>
951                 </entry>
952               </row>
953               <row>
954                 <entry>
955                   <para>
956                     <literal>fmr_cache</literal>
957                   </para>
958                 </entry>
959                 <entry>
960                   <para>
961                     <literal>1</literal>
962                   </para>
963                 </entry>
964                 <entry>
965                   <para>Non-zero to enable FMR caching.</para>
966                 </entry>
967               </row>
968               <row>
969                 <entry>
970                   <para>
971                     <literal>dev_failover</literal>
972                   </para>
973                 </entry>
974                 <entry>
975                   <para>
976                     <literal>0</literal>
977                   </para>
978                 </entry>
979                 <entry>
980                   <para>HCA failover for bonding (0 OFF, 1 ON, other values reserved).
981           </para>
982                 </entry>
983               </row>
984               <row>
985                 <entry>
986                   <para>
987                     <literal>require_privileged_port</literal>
988                   </para>
989                 </entry>
990                 <entry>
991                   <para>
992                     <literal>0</literal>
993                   </para>
994                 </entry>
995                 <entry>
996                   <para>Require privileged port when accepting connection.</para>
997                 </entry>
998               </row>
999               <row>
1000                 <entry>
1001                   <para>
1002                     <literal>use_privileged_port</literal>
1003                   </para>
1004                 </entry>
1005                 <entry>
1006                   <para>
1007                     <literal>1</literal>
1008                   </para>
1009                 </entry>
1010                 <entry>
1011                   <para>Use privileged port when initiating connection.</para>
1012                 </entry>
1013               </row>
1014               <row>
1015                 <entry>
1016                   <para>
1017                     <literal>wrq_sge</literal>
1018                   </para>
1019                 </entry>
1020                 <entry>
1021                   <para>
1022                     <literal>2</literal>
1023                   </para>
1024                 </entry>
1025                 <entry>
1026                   <para>Introduced in 2.10. Number scatter/gather element groups per
1027           work request.  Used to deal with fragmentations which can consume
1028           double the number of work requests.</para>
1029                 </entry>
1030               </row>
1031             </tbody>
1032           </tgroup>
1033         </informaltable>
1034     </section>
1035   </section>
1036   <section xml:id="nrstuning">
1037     <title>
1038     <indexterm>
1039       <primary>tuning</primary>
1040       <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1041     </indexterm>Network Request Scheduler (NRS) Tuning</title>
1042     <para>The Network Request Scheduler (NRS) allows the administrator to
1043     influence the order in which RPCs are handled at servers, on a per-PTLRPC
1044     service basis, by providing different policies that can be activated and
1045     tuned in order to influence the RPC ordering. The aim of this is to provide
1046     for better performance, and possibly discrete performance characteristics
1047     using future policies.</para>
1048     <para>The NRS policy state of a PTLRPC service can be read and set via the 
1049     <literal>{service}.nrs_policies</literal> tunable. To read a PTLRPC
1050     service's NRS policy state, run:</para>
1051     <screen>
1052 lctl get_param {service}.nrs_policies
1053 </screen>
1054     <para>For example, to read the NRS policy state of the 
1055     <literal>ost_io</literal> service, run:</para>
1056     <screen>
1057 $ lctl get_param ost.OSS.ost_io.nrs_policies
1058 ost.OSS.ost_io.nrs_policies=
1059
1060 regular_requests:
1061   - name: fifo
1062     state: started
1063     fallback: yes
1064     queued: 0
1065     active: 0
1066
1067   - name: crrn
1068     state: stopped
1069     fallback: no
1070     queued: 0
1071     active: 0
1072
1073   - name: orr
1074     state: stopped
1075     fallback: no
1076     queued: 0
1077     active: 0
1078
1079   - name: trr
1080     state: started
1081     fallback: no
1082     queued: 2420
1083     active: 268
1084
1085   - name: tbf
1086     state: stopped
1087     fallback: no
1088     queued: 0
1089     active: 0
1090
1091   - name: delay
1092     state: stopped
1093     fallback: no
1094     queued: 0
1095     active: 0
1096
1097 high_priority_requests:
1098   - name: fifo
1099     state: started
1100     fallback: yes
1101     queued: 0
1102     active: 0
1103
1104   - name: crrn
1105     state: stopped
1106     fallback: no
1107     queued: 0
1108     active: 0
1109
1110   - name: orr
1111     state: stopped
1112     fallback: no
1113     queued: 0
1114     active: 0
1115
1116   - name: trr
1117     state: stopped
1118     fallback: no
1119     queued: 0
1120     active: 0
1121
1122   - name: tbf
1123     state: stopped
1124     fallback: no
1125     queued: 0
1126     active: 0
1127
1128   - name: delay
1129     state: stopped
1130     fallback: no
1131     queued: 0
1132     active: 0
1133
1134 </screen>
1135     <para>NRS policy state is shown in either one or two sections, depending on
1136     the PTLRPC service being queried. The first section is named 
1137     <literal>regular_requests</literal> and is available for all PTLRPC
1138     services, optionally followed by a second section which is named 
1139     <literal>high_priority_requests</literal>. This is because some PTLRPC
1140     services are able to treat some types of RPCs as higher priority ones, such
1141     that they are handled by the server with higher priority compared to other,
1142     regular RPC traffic. For PTLRPC services that do not support high-priority
1143     RPCs, you will only see the 
1144     <literal>regular_requests</literal> section.</para>
1145     <para>There is a separate instance of each NRS policy on each PTLRPC
1146     service for handling regular and high-priority RPCs (if the service
1147     supports high-priority RPCs). For each policy instance, the following
1148     fields are shown:</para>
1149     <informaltable frame="all">
1150       <tgroup cols="2">
1151         <colspec colname="c1" colwidth="50*" />
1152         <colspec colname="c2" colwidth="50*" />
1153         <thead>
1154           <row>
1155             <entry>
1156               <para>
1157                 <emphasis role="bold">Field</emphasis>
1158               </para>
1159             </entry>
1160             <entry>
1161               <para>
1162                 <emphasis role="bold">Description</emphasis>
1163               </para>
1164             </entry>
1165           </row>
1166         </thead>
1167         <tbody>
1168           <row>
1169             <entry>
1170               <para>
1171                 <literal>name</literal>
1172               </para>
1173             </entry>
1174             <entry>
1175               <para>The name of the policy.</para>
1176             </entry>
1177           </row>
1178           <row>
1179             <entry>
1180               <para>
1181                 <literal>state</literal>
1182               </para>
1183             </entry>
1184             <entry>
1185               <para>The state of the policy; this can be any of 
1186               <literal>invalid, stopping, stopped, starting, started</literal>.
1187               A fully enabled policy is in the 
1188               <literal>started</literal> state.</para>
1189             </entry>
1190           </row>
1191           <row>
1192             <entry>
1193               <para>
1194                 <literal>fallback</literal>
1195               </para>
1196             </entry>
1197             <entry>
1198               <para>Whether the policy is acting as a fallback policy or not. A
1199               fallback policy is used to handle RPCs that other enabled
1200               policies fail to handle, or do not support the handling of. The
1201               possible values are 
1202               <literal>no, yes</literal>. Currently, only the FIFO policy can
1203               act as a fallback policy.</para>
1204             </entry>
1205           </row>
1206           <row>
1207             <entry>
1208               <para>
1209                 <literal>queued</literal>
1210               </para>
1211             </entry>
1212             <entry>
1213               <para>The number of RPCs that the policy has waiting to be
1214               serviced.</para>
1215             </entry>
1216           </row>
1217           <row>
1218             <entry>
1219               <para>
1220                 <literal>active</literal>
1221               </para>
1222             </entry>
1223             <entry>
1224               <para>The number of RPCs that the policy is currently
1225               handling.</para>
1226             </entry>
1227           </row>
1228         </tbody>
1229       </tgroup>
1230     </informaltable>
1231     <para>To enable an NRS policy on a PTLRPC service run:</para>
1232     <screen>
1233 lctl set_param {service}.nrs_policies=
1234 <replaceable>policy_name</replaceable>
1235 </screen>
1236     <para>This will enable the policy 
1237     <replaceable>policy_name</replaceable>for both regular and high-priority
1238     RPCs (if the PLRPC service supports high-priority RPCs) on the given
1239     service. For example, to enable the CRR-N NRS policy for the ldlm_cbd
1240     service, run:</para>
1241     <screen>
1242 $ lctl set_param ldlm.services.ldlm_cbd.nrs_policies=crrn
1243 ldlm.services.ldlm_cbd.nrs_policies=crrn
1244       
1245 </screen>
1246     <para>For PTLRPC services that support high-priority RPCs, you can also
1247     supply an optional 
1248     <replaceable>reg|hp</replaceable>token, in order to enable an NRS policy
1249     for handling only regular or high-priority RPCs on a given PTLRPC service,
1250     by running:</para>
1251     <screen>
1252 lctl set_param {service}.nrs_policies="
1253 <replaceable>policy_name</replaceable> 
1254 <replaceable>reg|hp</replaceable>"
1255 </screen>
1256     <para>For example, to enable the TRR policy for handling only regular, but
1257     not high-priority RPCs on the 
1258     <literal>ost_io</literal> service, run:</para>
1259     <screen>
1260 $ lctl set_param ost.OSS.ost_io.nrs_policies="trr reg"
1261 ost.OSS.ost_io.nrs_policies="trr reg"
1262       
1263 </screen>
1264     <note>
1265       <para>When enabling an NRS policy, the policy name must be given in
1266       lower-case characters, otherwise the operation will fail with an error
1267       message.</para>
1268     </note>
1269     <section>
1270       <title>
1271       <indexterm>
1272         <primary>tuning</primary>
1273         <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1274         <tertiary>first in, first out (FIFO) policy</tertiary>
1275       </indexterm>First In, First Out (FIFO) policy</title>
1276       <para>The first in, first out (FIFO) policy handles RPCs in a service in
1277       the same order as they arrive from the LNet layer, so no special
1278       processing takes place to modify the RPC handling stream. FIFO is the
1279       default policy for all types of RPCs on all PTLRPC services, and is
1280       always enabled irrespective of the state of other policies, so that it
1281       can be used as a backup policy, in case a more elaborate policy that has
1282       been enabled fails to handle an RPC, or does not support handling a given
1283       type of RPC.</para>
1284       <para>The FIFO policy has no tunables that adjust its behaviour.</para>
1285     </section>
1286     <section>
1287       <title>
1288       <indexterm>
1289         <primary>tuning</primary>
1290         <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1291         <tertiary>client round-robin over NIDs (CRR-N) policy</tertiary>
1292       </indexterm>Client Round-Robin over NIDs (CRR-N) policy</title>
1293       <para>The client round-robin over NIDs (CRR-N) policy performs batched
1294       round-robin scheduling of all types of RPCs, with each batch consisting
1295       of RPCs originating from the same client node, as identified by its NID.
1296       CRR-N aims to provide for better resource utilization across the cluster,
1297       and to help shorten completion times of jobs in some cases, by
1298       distributing available bandwidth more evenly across all clients.</para>
1299       <para>The CRR-N policy can be enabled on all types of PTLRPC services,
1300       and has the following tunable that can be used to adjust its
1301       behavior:</para>
1302       <itemizedlist>
1303         <listitem>
1304           <para>
1305             <literal>{service}.nrs_crrn_quantum</literal>
1306           </para>
1307           <para>The 
1308           <literal>{service}.nrs_crrn_quantum</literal> tunable determines the
1309           maximum allowed size of each batch of RPCs; the unit of measure is in
1310           number of RPCs. To read the maximum allowed batch size of a CRR-N
1311           policy, run:</para>
1312           <screen>
1313 lctl get_param {service}.nrs_crrn_quantum
1314 </screen>
1315           <para>For example, to read the maximum allowed batch size of a CRR-N
1316           policy on the ost_io service, run:</para>
1317           <screen>
1318 $ lctl get_param ost.OSS.ost_io.nrs_crrn_quantum
1319 ost.OSS.ost_io.nrs_crrn_quantum=reg_quantum:16
1320 hp_quantum:8
1321           
1322 </screen>
1323           <para>You can see that there is a separate maximum allowed batch size
1324           value for regular (
1325           <literal>reg_quantum</literal>) and high-priority (
1326           <literal>hp_quantum</literal>) RPCs (if the PTLRPC service supports
1327           high-priority RPCs).</para>
1328           <para>To set the maximum allowed batch size of a CRR-N policy on a
1329           given service, run:</para>
1330           <screen>
1331 lctl set_param {service}.nrs_crrn_quantum=
1332 <replaceable>1-65535</replaceable>
1333 </screen>
1334           <para>This will set the maximum allowed batch size on a given
1335           service, for both regular and high-priority RPCs (if the PLRPC
1336           service supports high-priority RPCs), to the indicated value.</para>
1337           <para>For example, to set the maximum allowed batch size on the
1338           ldlm_canceld service to 16 RPCs, run:</para>
1339           <screen>
1340 $ lctl set_param ldlm.services.ldlm_canceld.nrs_crrn_quantum=16
1341 ldlm.services.ldlm_canceld.nrs_crrn_quantum=16
1342           
1343 </screen>
1344           <para>For PTLRPC services that support high-priority RPCs, you can
1345           also specify a different maximum allowed batch size for regular and
1346           high-priority RPCs, by running:</para>
1347           <screen>
1348 $ lctl set_param {service}.nrs_crrn_quantum=
1349 <replaceable>reg_quantum|hp_quantum</replaceable>:
1350 <replaceable>1-65535</replaceable>"
1351 </screen>
1352           <para>For example, to set the maximum allowed batch size on the
1353           ldlm_canceld service, for high-priority RPCs to 32, run:</para>
1354           <screen>
1355 $ lctl set_param ldlm.services.ldlm_canceld.nrs_crrn_quantum="hp_quantum:32"
1356 ldlm.services.ldlm_canceld.nrs_crrn_quantum=hp_quantum:32
1357           
1358 </screen>
1359           <para>By using the last method, you can also set the maximum regular
1360           and high-priority RPC batch sizes to different values, in a single
1361           command invocation.</para>
1362         </listitem>
1363       </itemizedlist>
1364     </section>
1365     <section>
1366       <title>
1367       <indexterm>
1368         <primary>tuning</primary>
1369         <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1370         <tertiary>object-based round-robin (ORR) policy</tertiary>
1371       </indexterm>Object-based Round-Robin (ORR) policy</title>
1372       <para>The object-based round-robin (ORR) policy performs batched
1373       round-robin scheduling of bulk read write (brw) RPCs, with each batch
1374       consisting of RPCs that pertain to the same backend-file system object,
1375       as identified by its OST FID.</para>
1376       <para>The ORR policy is only available for use on the ost_io service. The
1377       RPC batches it forms can potentially consist of mixed bulk read and bulk
1378       write RPCs. The RPCs in each batch are ordered in an ascending manner,
1379       based on either the file offsets, or the physical disk offsets of each
1380       RPC (only applicable to bulk read RPCs).</para>
1381       <para>The aim of the ORR policy is to provide for increased bulk read
1382       throughput in some cases, by ordering bulk read RPCs (and potentially
1383       bulk write RPCs), and thus minimizing costly disk seek operations.
1384       Performance may also benefit from any resulting improvement in resource
1385       utilization, or by taking advantage of better locality of reference
1386       between RPCs.</para>
1387       <para>The ORR policy has the following tunables that can be used to
1388       adjust its behaviour:</para>
1389       <itemizedlist>
1390         <listitem>
1391           <para>
1392             <literal>ost.OSS.ost_io.nrs_orr_quantum</literal>
1393           </para>
1394           <para>The 
1395           <literal>ost.OSS.ost_io.nrs_orr_quantum</literal> tunable determines
1396           the maximum allowed size of each batch of RPCs; the unit of measure
1397           is in number of RPCs. To read the maximum allowed batch size of the
1398           ORR policy, run:</para>
1399           <screen>
1400 $ lctl get_param ost.OSS.ost_io.nrs_orr_quantum
1401 ost.OSS.ost_io.nrs_orr_quantum=reg_quantum:256
1402 hp_quantum:16
1403           
1404 </screen>
1405           <para>You can see that there is a separate maximum allowed batch size
1406           value for regular (
1407           <literal>reg_quantum</literal>) and high-priority (
1408           <literal>hp_quantum</literal>) RPCs (if the PTLRPC service supports
1409           high-priority RPCs).</para>
1410           <para>To set the maximum allowed batch size for the ORR policy,
1411           run:</para>
1412           <screen>
1413 $ lctl set_param ost.OSS.ost_io.nrs_orr_quantum=
1414 <replaceable>1-65535</replaceable>
1415 </screen>
1416           <para>This will set the maximum allowed batch size for both regular
1417           and high-priority RPCs, to the indicated value.</para>
1418           <para>You can also specify a different maximum allowed batch size for
1419           regular and high-priority RPCs, by running:</para>
1420           <screen>
1421 $ lctl set_param ost.OSS.ost_io.nrs_orr_quantum=
1422 <replaceable>reg_quantum|hp_quantum</replaceable>:
1423 <replaceable>1-65535</replaceable>
1424 </screen>
1425           <para>For example, to set the maximum allowed batch size for regular
1426           RPCs to 128, run:</para>
1427           <screen>
1428 $ lctl set_param ost.OSS.ost_io.nrs_orr_quantum=reg_quantum:128
1429 ost.OSS.ost_io.nrs_orr_quantum=reg_quantum:128
1430           
1431 </screen>
1432           <para>By using the last method, you can also set the maximum regular
1433           and high-priority RPC batch sizes to different values, in a single
1434           command invocation.</para>
1435         </listitem>
1436         <listitem>
1437           <para>
1438             <literal>ost.OSS.ost_io.nrs_orr_offset_type</literal>
1439           </para>
1440           <para>The 
1441           <literal>ost.OSS.ost_io.nrs_orr_offset_type</literal> tunable
1442           determines whether the ORR policy orders RPCs within each batch based
1443           on logical file offsets or physical disk offsets. To read the offset
1444           type value for the ORR policy, run:</para>
1445           <screen>
1446 $ lctl get_param ost.OSS.ost_io.nrs_orr_offset_type
1447 ost.OSS.ost_io.nrs_orr_offset_type=reg_offset_type:physical
1448 hp_offset_type:logical
1449           
1450 </screen>
1451           <para>You can see that there is a separate offset type value for
1452           regular (
1453           <literal>reg_offset_type</literal>) and high-priority (
1454           <literal>hp_offset_type</literal>) RPCs.</para>
1455           <para>To set the ordering type for the ORR policy, run:</para>
1456           <screen>
1457 $ lctl set_param ost.OSS.ost_io.nrs_orr_offset_type=
1458 <replaceable>physical|logical</replaceable>
1459 </screen>
1460           <para>This will set the offset type for both regular and
1461           high-priority RPCs, to the indicated value.</para>
1462           <para>You can also specify a different offset type for regular and
1463           high-priority RPCs, by running:</para>
1464           <screen>
1465 $ lctl set_param ost.OSS.ost_io.nrs_orr_offset_type=
1466 <replaceable>reg_offset_type|hp_offset_type</replaceable>:
1467 <replaceable>physical|logical</replaceable>
1468 </screen>
1469           <para>For example, to set the offset type for high-priority RPCs to
1470           physical disk offsets, run:</para>
1471           <screen>
1472 $ lctl set_param ost.OSS.ost_io.nrs_orr_offset_type=hp_offset_type:physical
1473 ost.OSS.ost_io.nrs_orr_offset_type=hp_offset_type:physical
1474 </screen>
1475           <para>By using the last method, you can also set offset type for
1476           regular and high-priority RPCs to different values, in a single
1477           command invocation.</para>
1478           <note>
1479             <para>Irrespective of the value of this tunable, only logical
1480             offsets can, and are used for ordering bulk write RPCs.</para>
1481           </note>
1482         </listitem>
1483         <listitem>
1484           <para>
1485             <literal>ost.OSS.ost_io.nrs_orr_supported</literal>
1486           </para>
1487           <para>The 
1488           <literal>ost.OSS.ost_io.nrs_orr_supported</literal> tunable determines
1489           the type of RPCs that the ORR policy will handle. To read the types
1490           of supported RPCs by the ORR policy, run:</para>
1491           <screen>
1492 $ lctl get_param ost.OSS.ost_io.nrs_orr_supported
1493 ost.OSS.ost_io.nrs_orr_supported=reg_supported:reads
1494 hp_supported=reads_and_writes
1495           
1496 </screen>
1497           <para>You can see that there is a separate supported 'RPC types'
1498           value for regular (
1499           <literal>reg_supported</literal>) and high-priority (
1500           <literal>hp_supported</literal>) RPCs.</para>
1501           <para>To set the supported RPC types for the ORR policy, run:</para>
1502           <screen>
1503 $ lctl set_param ost.OSS.ost_io.nrs_orr_supported=
1504 <replaceable>reads|writes|reads_and_writes</replaceable>
1505 </screen>
1506           <para>This will set the supported RPC types for both regular and
1507           high-priority RPCs, to the indicated value.</para>
1508           <para>You can also specify a different supported 'RPC types' value
1509           for regular and high-priority RPCs, by running:</para>
1510           <screen>
1511 $ lctl set_param ost.OSS.ost_io.nrs_orr_supported=
1512 <replaceable>reg_supported|hp_supported</replaceable>:
1513 <replaceable>reads|writes|reads_and_writes</replaceable>
1514 </screen>
1515           <para>For example, to set the supported RPC types to bulk read and
1516           bulk write RPCs for regular requests, run:</para>
1517           <screen>
1518 $ lctl set_param
1519 ost.OSS.ost_io.nrs_orr_supported=reg_supported:reads_and_writes
1520 ost.OSS.ost_io.nrs_orr_supported=reg_supported:reads_and_writes
1521           
1522 </screen>
1523           <para>By using the last method, you can also set the supported RPC
1524           types for regular and high-priority RPC to different values, in a
1525           single command invocation.</para>
1526         </listitem>
1527       </itemizedlist>
1528     </section>
1529     <section>
1530       <title>
1531       <indexterm>
1532         <primary>tuning</primary>
1533         <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1534         <tertiary>Target-based round-robin (TRR) policy</tertiary>
1535       </indexterm>Target-based Round-Robin (TRR) policy</title>
1536       <para>The target-based round-robin (TRR) policy performs batched
1537       round-robin scheduling of brw RPCs, with each batch consisting of RPCs
1538       that pertain to the same OST, as identified by its OST index.</para>
1539       <para>The TRR policy is identical to the object-based round-robin (ORR)
1540       policy, apart from using the brw RPC's target OST index instead of the
1541       backend-fs object's OST FID, for determining the RPC scheduling order.
1542       The goals of TRR are effectively the same as for ORR, and it uses the
1543       following tunables to adjust its behaviour:</para>
1544       <itemizedlist>
1545         <listitem>
1546           <para>
1547             <literal>ost.OSS.ost_io.nrs_trr_quantum</literal>
1548           </para>
1549           <para>The purpose of this tunable is exactly the same as for the 
1550           <literal>ost.OSS.ost_io.nrs_orr_quantum</literal> tunable for the ORR
1551           policy, and you can use it in exactly the same way.</para>
1552         </listitem>
1553         <listitem>
1554           <para>
1555             <literal>ost.OSS.ost_io.nrs_trr_offset_type</literal>
1556           </para>
1557           <para>The purpose of this tunable is exactly the same as for the 
1558           <literal>ost.OSS.ost_io.nrs_orr_offset_type</literal> tunable for the
1559           ORR policy, and you can use it in exactly the same way.</para>
1560         </listitem>
1561         <listitem>
1562           <para>
1563             <literal>ost.OSS.ost_io.nrs_trr_supported</literal>
1564           </para>
1565           <para>The purpose of this tunable is exactly the same as for the 
1566           <literal>ost.OSS.ost_io.nrs_orr_supported</literal> tunable for the
1567           ORR policy, and you can use it in exactly the sme way.</para>
1568         </listitem>
1569       </itemizedlist>
1570     </section>
1571     <section xml:id="tbftuning" condition='l26'>
1572       <title>
1573       <indexterm>
1574         <primary>tuning</primary>
1575         <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1576         <tertiary>Token Bucket Filter (TBF) policy</tertiary>
1577       </indexterm>Token Bucket Filter (TBF) policy</title>
1578       <para>The TBF (Token Bucket Filter) is a Lustre NRS policy which enables
1579       Lustre services to enforce the RPC rate limit on clients/jobs for QoS
1580       (Quality of Service) purposes.</para>
1581       <figure>
1582         <title>The internal structure of TBF policy</title>
1583         <mediaobject>
1584           <imageobject>
1585             <imagedata scalefit="1" width="50%"
1586             fileref="figures/TBF_policy.png" />
1587           </imageobject>
1588           <textobject>
1589             <phrase>The internal structure of TBF policy</phrase>
1590           </textobject>
1591         </mediaobject>
1592       </figure>
1593       <para>When a RPC request arrives, TBF policy puts it to a waiting queue
1594       according to its classification. The classification of RPC requests is
1595       based on either NID or JobID of the RPC according to the configure of
1596       TBF. TBF policy maintains multiple queues in the system, one queue for
1597       each category in the classification of RPC requests. The requests waits
1598       for tokens in the FIFO queue before they have been handled so as to keep
1599       the RPC rates under the limits.</para>
1600       <para>When Lustre services are too busy to handle all of the requests in
1601       time, all of the specified rates of the queues will not be satisfied.
1602       Nothing bad will happen except some of the RPC rates are slower than
1603       configured. In this case, the queue with higher rate will have an
1604       advantage over the queues with lower rates, but none of them will be
1605       starved.</para>
1606       <para>To manage the RPC rate of queues, we don't need to set the rate of
1607       each queue manually. Instead, we define rules which TBF policy matches to
1608       determine RPC rate limits. All of the defined rules are organized as an
1609       ordered list. Whenever a queue is newly created, it goes though the rule
1610       list and takes the first matched rule as its rule, so that the queue
1611       knows its RPC token rate. A rule can be added to or removed from the list
1612       at run time. Whenever the list of rules is changed, the queues will
1613       update their matched rules.</para>
1614       <section remap="h4">
1615         <title>Enable TBF policy</title>
1616         <para>Command:</para>
1617         <screen>lctl set_param ost.OSS.ost_io.nrs_policies="tbf &lt;<replaceable>policy</replaceable>&gt;"
1618         </screen>
1619         <para>For now, the RPCs can be classified into the different types
1620         according to their NID, JOBID, OPCode and UID/GID. When enabling TBF
1621         policy, you can specify one of the types, or just use "tbf" to enable
1622         all of them to do a fine-grained RPC requests classification.</para>
1623         <para>Example:</para>
1624         <screen>$ lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
1625 $ lctl set_param ost.OSS.ost_io.nrs_policies="tbf nid"
1626 $ lctl set_param ost.OSS.ost_io.nrs_policies="tbf jobid"
1627 $ lctl set_param ost.OSS.ost_io.nrs_policies="tbf opcode"
1628 $ lctl set_param ost.OSS.ost_io.nrs_policies="tbf uid"
1629 $ lctl set_param ost.OSS.ost_io.nrs_policies="tbf gid"</screen>
1630       </section>
1631       <section remap="h4">
1632         <title>Start a TBF rule</title>
1633         <para>The TBF rule is defined in the parameter
1634         <literal>ost.OSS.ost_io.nrs_tbf_rule</literal>.</para>
1635         <para>Command:</para>
1636         <screen>lctl set_param x.x.x.nrs_tbf_rule=
1637 "[reg|hp] start <replaceable>rule_name</replaceable> <replaceable>arguments</replaceable>..."
1638         </screen>
1639         <para>'<replaceable>rule_name</replaceable>' is a string of the TBF
1640         policy rule's name and '<replaceable>arguments</replaceable>' is a
1641         string to specify the detailed rule according to the different types.
1642         </para>
1643         <itemizedlist>
1644         <para>Next, the different types of TBF policies will be described.</para>
1645           <listitem>
1646             <para><emphasis role="bold">NID based TBF policy</emphasis></para>
1647             <para>Command:</para>
1648             <screen>lctl set_param x.x.x.nrs_tbf_rule=
1649 "[reg|hp] start <replaceable>rule_name</replaceable> nid={<replaceable>nidlist</replaceable>} rate=<replaceable>rate</replaceable>"
1650             </screen>
1651             <para>'<replaceable>nidlist</replaceable>' uses the same format
1652             as configuring LNET route. '<replaceable>rate</replaceable>' is
1653             the (upper limit) RPC rate of the rule.</para>
1654             <para>Example:</para>
1655             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1656 "start other_clients nid={192.168.*.*@tcp} rate=50"
1657 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1658 "start computes nid={192.168.1.[2-128]@tcp} rate=500"
1659 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1660 "start loginnode nid={192.168.1.1@tcp} rate=100"</screen>
1661             <para>In this example, the rate of processing RPC requests from
1662             compute nodes is at most 5x as fast as those from login nodes.
1663             The output of <literal>ost.OSS.ost_io.nrs_tbf_rule</literal> is
1664             like:</para>
1665             <screen>lctl get_param ost.OSS.ost_io.nrs_tbf_rule
1666 ost.OSS.ost_io.nrs_tbf_rule=
1667 regular_requests:
1668 CPT 0:
1669 loginnode {192.168.1.1@tcp} 100, ref 0
1670 computes {192.168.1.[2-128]@tcp} 500, ref 0
1671 other_clients {192.168.*.*@tcp} 50, ref 0
1672 default {*} 10000, ref 0
1673 high_priority_requests:
1674 CPT 0:
1675 loginnode {192.168.1.1@tcp} 100, ref 0
1676 computes {192.168.1.[2-128]@tcp} 500, ref 0
1677 other_clients {192.168.*.*@tcp} 50, ref 0
1678 default {*} 10000, ref 0</screen>
1679             <para>Also, the rule can be written in <literal>reg</literal> and
1680             <literal>hp</literal> formats:</para>
1681             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1682 "reg start loginnode nid={192.168.1.1@tcp} rate=100"
1683 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1684 "hp start loginnode nid={192.168.1.1@tcp} rate=100"</screen>
1685           </listitem>
1686           <listitem>
1687             <para><emphasis role="bold">JobID based TBF policy</emphasis></para>
1688             <para>For the JobID, please see
1689             <xref xmlns:xlink="http://www.w3.org/1999/xlink"
1690             linkend="jobstats" /> for more details.</para>
1691             <para>Command:</para>
1692             <screen>lctl set_param x.x.x.nrs_tbf_rule=
1693 "[reg|hp] start <replaceable>rule_name</replaceable> jobid={<replaceable>jobid_list</replaceable>} rate=<replaceable>rate</replaceable>"
1694             </screen>
1695             <para>Wildcard is supported in
1696             {<replaceable>jobid_list</replaceable>}.</para>
1697             <para>Example:</para>
1698             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1699 "start iozone_user jobid={iozone.500} rate=100"
1700 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1701 "start dd_user jobid={dd.*} rate=50"
1702 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1703 "start user1 jobid={*.600} rate=10"
1704 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1705 "start user2 jobid={io*.10* *.500} rate=200"</screen>
1706             <para>Also, the rule can be written in <literal>reg</literal> and
1707             <literal>hp</literal> formats:</para>
1708             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1709 "hp start iozone_user1 jobid={iozone.500} rate=100"
1710 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1711 "reg start iozone_user1 jobid={iozone.500} rate=100"</screen>
1712           </listitem>
1713           <listitem>
1714             <para><emphasis role="bold">Opcode based TBF policy</emphasis></para>
1715             <para>Command:</para>
1716             <screen>$ lctl set_param x.x.x.nrs_tbf_rule=
1717 "[reg|hp] start <replaceable>rule_name</replaceable> opcode={<replaceable>opcode_list</replaceable>} rate=<replaceable>rate</replaceable>"
1718             </screen>
1719             <para>Example:</para>
1720             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1721 "start user1 opcode={ost_read} rate=100"
1722 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1723 "start iozone_user1 opcode={ost_read ost_write} rate=200"</screen>
1724             <para>Also, the rule can be written in <literal>reg</literal> and
1725             <literal>hp</literal> formats:</para>
1726             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1727 "hp start iozone_user1 opcode={ost_read} rate=100"
1728 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1729 "reg start iozone_user1 opcode={ost_read} rate=100"</screen>
1730           </listitem>
1731           <listitem>
1732       <para><emphasis role="bold">UID/GID based TBF policy</emphasis></para>
1733             <para>Command:</para>
1734             <screen>$ lctl set_param ost.OSS.*.nrs_tbf_rule=\
1735 "[reg][hp] start <replaceable>rule_name</replaceable> uid={<replaceable>uid</replaceable>} rate=<replaceable>rate</replaceable>"
1736 $ lctl set_param ost.OSS.*.nrs_tbf_rule=\
1737 "[reg][hp] start <replaceable>rule_name</replaceable> gid={<replaceable>gid</replaceable>} rate=<replaceable>rate</replaceable>"</screen>
1738             <para>Exapmle:</para>
1739             <para>Limit the rate of RPC requests of the uid 500</para>
1740             <screen>$ lctl set_param ost.OSS.*.nrs_tbf_rule=\
1741 "start tbf_name uid={500} rate=100"</screen>
1742             <para>Limit the rate of RPC requests of the gid 500</para>
1743             <screen>$ lctl set_param ost.OSS.*.nrs_tbf_rule=\
1744 "start tbf_name gid={500} rate=100"</screen>
1745             <para>Also, you can use the following rule to control all reqs
1746             to mds:</para>
1747             <para>Start the tbf uid QoS on MDS:</para>
1748             <screen>$ lctl set_param mds.MDS.*.nrs_policies="tbf uid"</screen>
1749             <para>Limit the rate of RPC requests of the uid 500</para>
1750             <screen>$ lctl set_param mds.MDS.*.nrs_tbf_rule=\
1751 "start tbf_name uid={500} rate=100"</screen>
1752           </listitem>
1753           <listitem>
1754             <para><emphasis role="bold">Policy combination</emphasis></para>
1755             <para>To support TBF rules with complex expressions of conditions,
1756             TBF classifier is extented to classify RPC in a more fine-grained
1757             way. This feature supports logical conditional conjunction and
1758             disjunction operations among different types.
1759             In the rule:
1760             "&amp;" represents the conditional conjunction and
1761             "," represents the conditional disjunction.</para>
1762             <para>Example:</para>
1763             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1764 "start comp_rule opcode={ost_write}&amp;jobid={dd.0},\
1765 nid={192.168.1.[1-128]@tcp 0@lo} rate=100"</screen>
1766             <para>In this example, those RPCs whose <literal>opcode</literal> is
1767             ost_write and <literal>jobid</literal> is dd.0, or
1768             <literal>nid</literal> satisfies the condition of
1769             {192.168.1.[1-128]@tcp 0@lo} will be processed at the rate of 100
1770             req/sec.
1771             The output of <literal>ost.OSS.ost_io.nrs_tbf_rule</literal>is like:
1772             </para>
1773             <screen>$ lctl get_param ost.OSS.ost_io.nrs_tbf_rule
1774 ost.OSS.ost_io.nrs_tbf_rule=
1775 regular_requests:
1776 CPT 0:
1777 comp_rule opcode={ost_write}&amp;jobid={dd.0},nid={192.168.1.[1-128]@tcp 0@lo} 100, ref 0
1778 default * 10000, ref 0
1779 CPT 1:
1780 comp_rule opcode={ost_write}&amp;jobid={dd.0},nid={192.168.1.[1-128]@tcp 0@lo} 100, ref 0
1781 default * 10000, ref 0
1782 high_priority_requests:
1783 CPT 0:
1784 comp_rule opcode={ost_write}&amp;jobid={dd.0},nid={192.168.1.[1-128]@tcp 0@lo} 100, ref 0
1785 default * 10000, ref 0
1786 CPT 1:
1787 comp_rule opcode={ost_write}&amp;jobid={dd.0},nid={192.168.1.[1-128]@tcp 0@lo} 100, ref 0
1788 default * 10000, ref 0</screen>
1789             <para>Example:</para>
1790             <screen>$ lctl set_param ost.OSS.*.nrs_tbf_rule=\
1791 "start tbf_name uid={500}&amp;gid={500} rate=100"</screen>
1792             <para>In this example, those RPC requests whose uid is 500 and
1793             gid is 500 will be processed at the rate of 100 req/sec.</para>
1794           </listitem>
1795         </itemizedlist>
1796       </section>
1797       <section remap="h4">
1798           <title>Change a TBF rule</title>
1799           <para>Command:</para>
1800           <screen>lctl set_param x.x.x.nrs_tbf_rule=
1801 "[reg|hp] change <replaceable>rule_name</replaceable> rate=<replaceable>rate</replaceable>"
1802           </screen>
1803           <para>Example:</para>
1804           <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1805 "change loginnode rate=200"
1806 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1807 "reg change loginnode rate=200"
1808 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1809 "hp change loginnode rate=200"
1810 </screen>
1811       </section>
1812       <section remap="h4">
1813           <title>Stop a TBF rule</title>
1814           <para>Command:</para>
1815           <screen>lctl set_param x.x.x.nrs_tbf_rule="[reg|hp] stop
1816 <replaceable>rule_name</replaceable>"</screen>
1817           <para>Example:</para>
1818           <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop loginnode"
1819 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule="reg stop loginnode"
1820 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule="hp stop loginnode"</screen>
1821       </section>
1822       <section remap="h4">
1823         <title>Rule options</title>
1824         <para>To support more flexible rule conditions, the following options
1825         are added.</para>
1826         <itemizedlist>
1827           <listitem>
1828             <para><emphasis role="bold">Reordering of TBF rules</emphasis></para>
1829             <para>By default, a newly started rule is prior to the old ones,
1830             but by specifying the argument '<literal>rank=</literal>' when
1831             inserting a new rule with "<literal>start</literal>" command,
1832             the rank of the rule can be changed. Also, it can be changed by
1833             "<literal>change</literal>" command.
1834             </para>
1835             <para>Command:</para>
1836             <screen>lctl set_param ost.OSS.ost_io.nrs_tbf_rule=
1837 "start <replaceable>rule_name</replaceable> <replaceable>arguments</replaceable>... rank=<replaceable>obj_rule_name</replaceable>"
1838 lctl set_param ost.OSS.ost_io.nrs_tbf_rule=
1839 "change <replaceable>rule_name</replaceable> rate=<replaceable>rate</replaceable> rank=<replaceable>obj_rule_name</replaceable>"
1840 </screen>
1841             <para>By specifying the existing rule
1842             '<replaceable>obj_rule_name</replaceable>', the new rule
1843             '<replaceable>rule_name</replaceable>' will be moved to the front of
1844             '<replaceable>obj_rule_name</replaceable>'.</para>
1845             <para>Example:</para>
1846             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1847 "start computes nid={192.168.1.[2-128]@tcp} rate=500"
1848 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1849 "start user1 jobid={iozone.500 dd.500} rate=100"
1850 $ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=\
1851 "start iozone_user1 opcode={ost_read ost_write} rate=200 rank=computes"</screen>
1852             <para>In this example, rule "iozone_user1" is added to the front of
1853             rule "computes". We can see the order by the following command:
1854             </para>
1855             <screen>$ lctl get_param ost.OSS.ost_io.nrs_tbf_rule
1856 ost.OSS.ost_io.nrs_tbf_rule=
1857 regular_requests:
1858 CPT 0:
1859 user1 jobid={iozone.500 dd.500} 100, ref 0
1860 iozone_user1 opcode={ost_read ost_write} 200, ref 0
1861 computes nid={192.168.1.[2-128]@tcp} 500, ref 0
1862 default * 10000, ref 0
1863 CPT 1:
1864 user1 jobid={iozone.500 dd.500} 100, ref 0
1865 iozone_user1 opcode={ost_read ost_write} 200, ref 0
1866 computes nid={192.168.1.[2-128]@tcp} 500, ref 0
1867 default * 10000, ref 0
1868 high_priority_requests:
1869 CPT 0:
1870 user1 jobid={iozone.500 dd.500} 100, ref 0
1871 iozone_user1 opcode={ost_read ost_write} 200, ref 0
1872 computes nid={192.168.1.[2-128]@tcp} 500, ref 0
1873 default * 10000, ref 0
1874 CPT 1:
1875 user1 jobid={iozone.500 dd.500} 100, ref 0
1876 iozone_user1 opcode={ost_read ost_write} 200, ref 0
1877 computes nid={192.168.1.[2-128]@tcp} 500, ref 0
1878 default * 10000, ref 0</screen>
1879           </listitem>
1880           <listitem>
1881             <para><emphasis role="bold">TBF realtime policies under congestion
1882             </emphasis></para>
1883             <para>During TBF evaluation, we find that when the sum of I/O
1884             bandwidth requirements for all classes exceeds the system capacity,
1885             the classes with the same rate limits get less bandwidth than if
1886             preconfigured evenly. The reason for this is the heavy load on a
1887             congested server will result in some missed deadlines for some
1888             classes. The number of the calculated tokens may be larger than 1
1889             during dequeuing. In the original implementation, all classes are
1890             equally handled to simply discard exceeding tokens.</para>
1891             <para>Thus, a Hard Token Compensation (HTC) strategy has been
1892             implemented. A class can be configured with the HTC feature by the
1893             rule it matches. This feature means that requests in this kind of
1894             class queues have high real-time requirements and that the bandwidth
1895             assignment must be satisfied as good as possible. When deadline
1896             misses happen, the class keeps the deadline unchanged and the time
1897             residue(the remainder of elapsed time divided by 1/r) is compensated
1898             to the next round. This ensures that the next idle I/O thread will
1899             always select this class to serve until all accumulated exceeding
1900             tokens are handled or there are no pending requests in the class
1901             queue.</para>
1902             <para>Command:</para>
1903             <para>A new command format is added to enable the realtime feature
1904             for a rule:</para>
1905             <screen>lctl set_param x.x.x.nrs_tbf_rule=\
1906 "start <replaceable>rule_name</replaceable> <replaceable>arguments</replaceable>... realtime=1</screen>
1907             <para>Example:</para>
1908             <screen>$ lctl set_param ost.OSS.ost_io.nrs_tbf_rule=
1909 "start realjob jobid={dd.0} rate=100 realtime=1</screen>
1910             <para>This example rule means the RPC requests whose JobID is dd.0
1911             will be processed at the rate of 100req/sec in realtime.</para>
1912           </listitem>
1913         </itemizedlist>
1914       </section>
1915     </section>
1916     <section xml:id="delaytuning" condition='l2A'>
1917       <title>
1918       <indexterm>
1919         <primary>tuning</primary>
1920         <secondary>Network Request Scheduler (NRS) Tuning</secondary>
1921         <tertiary>Delay policy</tertiary>
1922       </indexterm>Delay policy</title>
1923       <para>The NRS Delay policy seeks to perturb the timing of request
1924       processing at the PtlRPC layer, with the goal of simulating high server
1925       load, and finding and exposing timing related problems. When this policy
1926       is active, upon arrival of a request the policy will calculate an offset,
1927       within a defined, user-configurable range, from the request arrival
1928       time, to determine a time after which the request should be handled.
1929       The request is then stored using the cfs_binheap implementation,
1930       which sorts the request according to the assigned start time.
1931       Requests are removed from the binheap for handling once their start
1932       time has been passed.</para>
1933       <para>The Delay policy can be enabled on all types of PtlRPC services,
1934       and has the following tunables that can be used to adjust its behavior:
1935       </para>
1936       <itemizedlist>
1937         <listitem>
1938           <para>
1939             <literal>{service}.nrs_delay_min</literal>
1940           </para>
1941           <para>The
1942           <literal>{service}.nrs_delay_min</literal> tunable controls the
1943           minimum amount of time, in seconds, that a request will be delayed by
1944           this policy.  The default is 5 seconds. To read this value run:</para>
1945           <screen>
1946 lctl get_param {service}.nrs_delay_min</screen>
1947           <para>For example, to read the minimum delay set on the ost_io
1948           service, run:</para>
1949           <screen>
1950 $ lctl get_param ost.OSS.ost_io.nrs_delay_min
1951 ost.OSS.ost_io.nrs_delay_min=reg_delay_min:5
1952 hp_delay_min:5</screen>
1953         <para>To set the minimum delay in RPC processing, run:</para>
1954         <screen>
1955 lctl set_param {service}.nrs_delay_min=<replaceable>0-65535</replaceable></screen>
1956         <para>This will set the minimum delay time on a given service, for both
1957         regular and high-priority RPCs (if the PtlRPC service supports
1958         high-priority RPCs), to the indicated value.</para>
1959         <para>For example, to set the minimum delay time on the ost_io service
1960         to 10, run:</para>
1961         <screen>
1962 $ lctl set_param ost.OSS.ost_io.nrs_delay_min=10
1963 ost.OSS.ost_io.nrs_delay_min=10</screen>
1964         <para>For PtlRPC services that support high-priority RPCs, to set a
1965         different minimum delay time for regular and high-priority RPCs, run:
1966         </para>
1967         <screen>
1968 lctl set_param {service}.nrs_delay_min=<replaceable>reg_delay_min|hp_delay_min</replaceable>:<replaceable>0-65535</replaceable>
1969         </screen>
1970         <para>For example, to set the minimum delay time on the ost_io service
1971         for high-priority RPCs to 3, run:</para>
1972         <screen>
1973 $ lctl set_param ost.OSS.ost_io.nrs_delay_min=hp_delay_min:3
1974 ost.OSS.ost_io.nrs_delay_min=hp_delay_min:3</screen>
1975         <para>Note, in all cases the minimum delay time cannot exceed the
1976         maximum delay time.</para>
1977         </listitem>
1978         <listitem>
1979           <para>
1980             <literal>{service}.nrs_delay_max</literal>
1981           </para>
1982           <para>The
1983           <literal>{service}.nrs_delay_max</literal> tunable controls the
1984           maximum amount of time, in seconds, that a request will be delayed by
1985           this policy.  The default is 300 seconds. To read this value run:
1986           </para>
1987           <screen>lctl get_param {service}.nrs_delay_max</screen>
1988           <para>For example, to read the maximum delay set on the ost_io
1989           service, run:</para>
1990           <screen>
1991 $ lctl get_param ost.OSS.ost_io.nrs_delay_max
1992 ost.OSS.ost_io.nrs_delay_max=reg_delay_max:300
1993 hp_delay_max:300</screen>
1994         <para>To set the maximum delay in RPC processing, run:</para>
1995         <screen>lctl set_param {service}.nrs_delay_max=<replaceable>0-65535</replaceable>
1996 </screen>
1997         <para>This will set the maximum delay time on a given service, for both
1998         regular and high-priority RPCs (if the PtlRPC service supports
1999         high-priority RPCs), to the indicated value.</para>
2000         <para>For example, to set the maximum delay time on the ost_io service
2001         to 60, run:</para>
2002         <screen>
2003 $ lctl set_param ost.OSS.ost_io.nrs_delay_max=60
2004 ost.OSS.ost_io.nrs_delay_max=60</screen>
2005         <para>For PtlRPC services that support high-priority RPCs, to set a
2006         different maximum delay time for regular and high-priority RPCs, run:
2007         </para>
2008         <screen>lctl set_param {service}.nrs_delay_max=<replaceable>reg_delay_max|hp_delay_max</replaceable>:<replaceable>0-65535</replaceable></screen>
2009         <para>For example, to set the maximum delay time on the ost_io service
2010         for high-priority RPCs to 30, run:</para>
2011         <screen>
2012 $ lctl set_param ost.OSS.ost_io.nrs_delay_max=hp_delay_max:30
2013 ost.OSS.ost_io.nrs_delay_max=hp_delay_max:30</screen>
2014         <para>Note, in all cases the maximum delay time cannot be less than the
2015         minimum delay time.</para>
2016         </listitem>
2017         <listitem>
2018           <para>
2019             <literal>{service}.nrs_delay_pct</literal>
2020           </para>
2021           <para>The
2022           <literal>{service}.nrs_delay_pct</literal> tunable controls the
2023           percentage of requests that will be delayed by this policy. The
2024           default is 100. Note, when a request is not selected for handling by
2025           the delay policy due to this variable then the request will be handled
2026           by whatever fallback policy is defined for that service. If no other
2027           fallback policy is defined then the request will be handled by the
2028           FIFO policy.  To read this value run:</para>
2029           <screen>lctl get_param {service}.nrs_delay_pct</screen>
2030           <para>For example, to read the percentage of requests being delayed on
2031           the ost_io service, run:</para>
2032           <screen>
2033 $ lctl get_param ost.OSS.ost_io.nrs_delay_pct
2034 ost.OSS.ost_io.nrs_delay_pct=reg_delay_pct:100
2035 hp_delay_pct:100</screen>
2036         <para>To set the percentage of delayed requests, run:</para>
2037         <screen>
2038 lctl set_param {service}.nrs_delay_pct=<replaceable>0-100</replaceable></screen>
2039         <para>This will set the percentage of requests delayed on a given
2040         service, for both regular and high-priority RPCs (if the PtlRPC service
2041         supports high-priority RPCs), to the indicated value.</para>
2042         <para>For example, to set the percentage of delayed requests on the
2043         ost_io service to 50, run:</para>
2044         <screen>
2045 $ lctl set_param ost.OSS.ost_io.nrs_delay_pct=50
2046 ost.OSS.ost_io.nrs_delay_pct=50
2047 </screen>
2048         <para>For PtlRPC services that support high-priority RPCs, to set a
2049         different delay percentage for regular and high-priority RPCs, run:
2050         </para>
2051         <screen>lctl set_param {service}.nrs_delay_pct=<replaceable>reg_delay_pct|hp_delay_pct</replaceable>:<replaceable>0-100</replaceable>
2052 </screen>
2053         <para>For example, to set the percentage of delayed requests on the
2054         ost_io service for high-priority RPCs to 5, run:</para>
2055         <screen>$ lctl set_param ost.OSS.ost_io.nrs_delay_pct=hp_delay_pct:5
2056 ost.OSS.ost_io.nrs_delay_pct=hp_delay_pct:5
2057 </screen>
2058         </listitem>
2059       </itemizedlist>
2060     </section>
2061   </section>
2062   <section xml:id="tuning_lockless_IO">
2063     <title>
2064     <indexterm>
2065       <primary>tuning</primary>
2066       <secondary>lockless I/O</secondary>
2067     </indexterm>Lockless I/O Tunables</title>
2068     <para>The lockless I/O tunable feature allows servers to ask clients to do
2069     lockless I/O (the server does the locking on behalf of clients) for
2070     contended files to avoid lock ping-pong.</para>
2071     <para>The lockless I/O patch introduces these tunables:</para>
2072     <itemizedlist>
2073       <listitem>
2074         <para>
2075           <emphasis role="bold">OST-side:</emphasis>
2076         </para>
2077         <screen>
2078 ldlm.namespaces.filter-<replaceable>fsname</replaceable>-*.
2079 </screen>
2080         <para>
2081         <literal>contended_locks</literal>- If the number of lock conflicts in
2082         the scan of granted and waiting queues at contended_locks is exceeded,
2083         the resource is considered to be contended.</para>
2084         <para>
2085         <literal>contention_seconds</literal>- The resource keeps itself in a
2086         contended state as set in the parameter.</para>
2087         <para>
2088         <literal>max_nolock_bytes</literal>- Server-side locking set only for
2089         requests less than the blocks set in the
2090         <literal>max_nolock_bytes</literal> parameter. If this tunable is
2091         set to zero (0), it disables server-side locking for read/write
2092         requests.</para>
2093       </listitem>
2094       <listitem>
2095         <para>
2096           <emphasis role="bold">Client-side:</emphasis>
2097         </para>
2098         <screen>llite.<replaceable>fsname</replaceable>-*</screen>
2099         <para>
2100         <literal>contention_seconds</literal>- 
2101         <literal>llite</literal> inode remembers its contended state for the
2102         time specified in this parameter.</para>
2103       </listitem>
2104       <listitem>
2105         <para>
2106           <emphasis role="bold">Client-side statistics:</emphasis>
2107         </para>
2108         <para>The 
2109         <literal>llite.<replaceable>fsname</replaceable>-*.stats</literal>
2110         parameter has several entries for lockless I/O statistics.</para>
2111         <para>
2112         <literal>lockless_read_bytes</literal> and 
2113         <literal>lockless_write_bytes</literal>- To count the total bytes read
2114         or written, the client makes its own decisions based on the request
2115         size. The client does not communicate with the server if the request
2116         size is smaller than the 
2117         <literal>min_nolock_size</literal>, without acquiring locks by the
2118         client.</para>
2119       </listitem>
2120     </itemizedlist>
2121   </section>
2122   <section condition="l29">
2123       <title>
2124         <indexterm>
2125           <primary>tuning</primary>
2126           <secondary>with lfs ladvise</secondary>
2127         </indexterm>
2128         Server-Side Advice and Hinting
2129       </title>
2130       <section><title>Overview</title>
2131       <para>Use the <literal>lfs ladvise</literal> command to give file access
2132       advices or hints to servers.</para>
2133       <screen>lfs ladvise [--advice|-a ADVICE ] [--background|-b]
2134 [--start|-s START[kMGT]]
2135 {[--end|-e END[kMGT]] | [--length|-l LENGTH[kMGT]]}
2136 <emphasis>file</emphasis> ...
2137       </screen>
2138       <para>
2139         <informaltable frame="all">
2140           <tgroup cols="2">
2141           <colspec colname="c1" colwidth="50*"/>
2142           <colspec colname="c2" colwidth="50*"/>
2143           <thead>
2144             <row>
2145               <entry>
2146                 <para><emphasis role="bold">Option</emphasis></para>
2147               </entry>
2148               <entry>
2149                 <para><emphasis role="bold">Description</emphasis></para>
2150               </entry>
2151             </row>
2152           </thead>
2153           <tbody>
2154             <row>
2155               <entry>
2156                 <para><literal>-a</literal>, <literal>--advice=</literal>
2157                 <literal>ADVICE</literal></para>
2158               </entry>
2159               <entry>
2160                 <para>Give advice or hint of type <literal>ADVICE</literal>.
2161                 Advice types are:</para>
2162                 <para><literal>willread</literal> to prefetch data into server
2163                 cache</para>
2164                 <para><literal>dontneed</literal> to cleanup data cache on
2165                 server</para>
2166                 <para><literal>lockahead</literal> Request an LDLM extent lock
2167                 of the given mode on the given byte range </para>
2168                 <para><literal>noexpand</literal> Disable extent lock expansion
2169                 behavior for I/O to this file descriptor</para>
2170               </entry>
2171             </row>
2172             <row>
2173               <entry>
2174                 <para><literal>-b</literal>, <literal>--background</literal>
2175                 </para>
2176               </entry>
2177               <entry>
2178                 <para>Enable the advices to be sent and handled asynchronously.
2179                 </para>
2180               </entry>
2181             </row>
2182             <row>
2183               <entry>
2184                 <para><literal>-s</literal>, <literal>--start=</literal>
2185                         <literal>START_OFFSET</literal></para>
2186               </entry>
2187               <entry>
2188                 <para>File range starts from <literal>START_OFFSET</literal>
2189                 </para>
2190                 </entry>
2191             </row>
2192             <row>
2193                 <entry>
2194                     <para><literal>-e</literal>, <literal>--end=</literal>
2195                         <literal>END_OFFSET</literal></para>
2196                 </entry>
2197                 <entry>
2198                     <para>File range ends at (not including)
2199                     <literal>END_OFFSET</literal>.  This option may not be
2200                     specified at the same time as the <literal>-l</literal>
2201                     option.</para>
2202                 </entry>
2203             </row>
2204             <row>
2205                 <entry>
2206                     <para><literal>-l</literal>, <literal>--length=</literal>
2207                         <literal>LENGTH</literal></para>
2208                 </entry>
2209                 <entry>
2210                   <para>File range has length of <literal>LENGTH</literal>.
2211                   This option may not be specified at the same time as the
2212                   <literal>-e</literal> option.</para>
2213                 </entry>
2214             </row>
2215             <row>
2216                 <entry>
2217                     <para><literal>-m</literal>, <literal>--mode=</literal>
2218                         <literal>MODE</literal></para>
2219                 </entry>
2220                 <entry>
2221                   <para>Lockahead request mode <literal>{READ,WRITE}</literal>.
2222                   Request a lock with this mode.</para>
2223                 </entry>
2224             </row>
2225           </tbody>
2226           </tgroup>
2227         </informaltable>
2228       </para>
2229       <para>Typically, <literal>lfs ladvise</literal> forwards the advice to
2230       Lustre servers without guaranteeing when and what servers will react to
2231       the advice. Actions may or may not triggered when the advices are
2232       recieved, depending on the type of the advice, as well as the real-time
2233       decision of the affected server-side components.</para>
2234       <para>A typical usage of ladvise is to enable applications and users with
2235       external knowledge to intervene in server-side cache management. For
2236       example, if a bunch of different clients are doing small random reads of a
2237       file, prefetching pages into OSS cache with big linear reads before the
2238       random IO is a net benefit. Fetching that data into each client cache with
2239       fadvise() may not be, due to much more data being sent to the client.
2240       </para>
2241       <para>
2242       <literal>ladvise lockahead</literal> is different in that it attempts to
2243       control LDLM locking behavior by explicitly requesting LDLM locks in
2244       advance of use.  This does not directly affect caching behavior, instead
2245       it is used in special cases to avoid pathological results (lock exchange)
2246       from the normal LDLM locking behavior.
2247       </para>
2248       <para>
2249       Note that the <literal>noexpand</literal> advice works on a specific
2250       file descriptor, so using it via lfs has no effect.  It must be used
2251       on a particular file descriptor which is used for i/o to have any effect.
2252       </para>
2253       <para>The main difference between the Linux <literal>fadvise()</literal>
2254       system call and <literal>lfs ladvise</literal> is that
2255       <literal>fadvise()</literal> is only a client side mechanism that does
2256       not pass the advice to the filesystem, while <literal>ladvise</literal>
2257       can send advices or hints to the Lustre server side.</para>
2258       </section>
2259       <section><title>Examples</title>
2260         <para>The following example gives the OST(s) holding the first 1GB of
2261         <literal>/mnt/lustre/file1</literal>a hint that the first 1GB of the
2262         file will be read soon.</para>
2263         <screen>client1$ lfs ladvise -a willread -s 0 -e 1048576000 /mnt/lustre/file1
2264         </screen>
2265         <para>The following example gives the OST(s) holding the first 1GB of
2266         <literal>/mnt/lustre/file1</literal> a hint that the first 1GB of file
2267         will not be read in the near future, thus the OST(s) could clear the
2268         cache of the file in the memory.</para>
2269         <screen>client1$ lfs ladvise -a dontneed -s 0 -e 1048576000 /mnt/lustre/file1
2270         </screen>
2271         <para>The following example requests an LDLM read lock on the first
2272         1 MiB of <literal>/mnt/lustre/file1</literal>.  This will attempt to
2273         request a lock from the OST holding that region of the file.</para>
2274         <screen>client1$ lfs ladvise -a lockahead -m READ -s 0 -e 1M /mnt/lustre/file1
2275         </screen>
2276         <para>The following example requests an LDLM write lock on
2277         [3 MiB, 10 MiB] of <literal>/mnt/lustre/file1</literal>.  This will
2278         attempt to request a lock from the OST holding that region of the
2279         file.</para>
2280         <screen>client1$ lfs ladvise -a lockahead -m WRITE -s 3M -e 10M /mnt/lustre/file1
2281         </screen>
2282       </section>
2283   </section>
2284   <section condition="l29">
2285       <title>
2286           <indexterm>
2287               <primary>tuning</primary>
2288               <secondary>Large Bulk IO</secondary>
2289           </indexterm>
2290           Large Bulk IO (16MB RPC)
2291       </title>
2292       <section><title>Overview</title>
2293           <para>Beginning with Lustre 2.9, Lustre is extended to support RPCs up
2294           to 16MB in size. By enabling a larger RPC size, fewer RPCs will be
2295           required to transfer the same amount of data between clients and
2296           servers.  With a larger RPC size, the OSS can submit more data to the
2297           underlying disks at once, therefore it can produce larger disk I/Os
2298           to fully utilize the increasing bandwidth of disks.</para>
2299           <para>At client connection time, clients will negotiate with
2300           servers what the maximum RPC size it is possible to use, but the
2301           client can always send RPCs smaller than this maximum.</para>
2302           <para>The parameter <literal>brw_size</literal> is used on the OST
2303           to tell the client the maximum (preferred) IO size.  All clients that
2304           talk to this target should never send an RPC greater than this size.
2305           Clients can individually set a smaller RPC size limit via the
2306           <literal>osc.*.max_pages_per_rpc</literal> tunable.
2307           </para>
2308           <note>
2309           <para>The smallest <literal>brw_size</literal> that can be set for
2310           ZFS OSTs is the <literal>recordsize</literal> of that dataset.  This
2311           ensures that the client can always write a full ZFS file block if it
2312           has enough dirty data, and does not otherwise force it to do read-
2313           modify-write operations for every RPC.
2314           </para>
2315           </note>
2316       </section>
2317       <section><title>Usage</title>
2318           <para>In order to enable a larger RPC size,
2319           <literal>brw_size</literal> must be changed to an IO size value up to
2320           16MB.  To temporarily change <literal>brw_size</literal>, the
2321           following command should be run on the OSS:</para>
2322           <screen>oss# lctl set_param obdfilter.<replaceable>fsname</replaceable>-OST*.brw_size=16</screen>
2323           <para>To persistently change <literal>brw_size</literal>, the
2324           following command should be run:</para>
2325           <screen>oss# lctl set_param -P obdfilter.<replaceable>fsname</replaceable>-OST*.brw_size=16</screen>
2326           <para>When a client connects to an OST target, it will fetch
2327           <literal>brw_size</literal> from the target and pick the maximum value
2328           of <literal>brw_size</literal> and its local setting for
2329           <literal>max_pages_per_rpc</literal> as the actual RPC size.
2330           Therefore, the <literal>max_pages_per_rpc</literal> on the client side
2331           would have to be set to 16M, or 4096 if the PAGESIZE is 4KB, to enable
2332           a 16MB RPC.  To temporarily make the change, the following command
2333           should be run on the client to set
2334           <literal>max_pages_per_rpc</literal>:</para>
2335           <screen>client$ lctl set_param osc.<replaceable>fsname</replaceable>-OST*.max_pages_per_rpc=16M</screen>
2336           <para>To persistently make this change, the following command should
2337           be run:</para>
2338           <screen>client$ lctl set_param -P obdfilter.<replaceable>fsname</replaceable>-OST*.osc.max_pages_per_rpc=16M</screen>
2339           <caution><para>The <literal>brw_size</literal> of an OST can be
2340           changed on the fly.  However, clients have to be remounted to
2341           renegotiate the new maximum RPC size.</para></caution>
2342       </section>
2343   </section>
2344   <section xml:id="tuning_IO_small_files">
2345     <title>
2346     <indexterm>
2347       <primary>tuning</primary>
2348       <secondary>for small files</secondary>
2349     </indexterm>Improving Lustre I/O Performance for Small Files</title>
2350     <para>An environment where an application writes small file chunks from
2351     many clients to a single file can result in poor I/O performance. To
2352     improve the performance of the Lustre file system with small files:</para>
2353     <itemizedlist>
2354       <listitem>
2355         <para>Have the application aggregate writes some amount before
2356         submitting them to the Lustre file system. By default, the Lustre
2357         software enforces POSIX coherency semantics, so it results in lock
2358         ping-pong between client nodes if they are all writing to the same
2359         file at one time.</para>
2360         <para>Using MPI-IO Collective Write functionality in
2361         the Lustre ADIO driver is one way to achieve this in a straight
2362         forward manner if the application is already using MPI-IO.</para>
2363       </listitem>
2364       <listitem>
2365         <para>Have the application do 4kB
2366         <literal>O_DIRECT</literal> sized I/O to the file and disable locking
2367         on the output file. This avoids partial-page IO submissions and, by
2368         disabling locking, you avoid contention between clients.</para>
2369       </listitem>
2370       <listitem>
2371         <para>Have the application write contiguous data.</para>
2372       </listitem>
2373       <listitem>
2374         <para>Add more disks or use SSD disks for the OSTs. This dramatically
2375         improves the IOPS rate. Consider creating larger OSTs rather than many
2376         smaller OSTs due to less overhead (journal, connections, etc).</para>
2377       </listitem>
2378       <listitem>
2379         <para>Use RAID-1+0 OSTs instead of RAID-5/6. There is RAID parity
2380         overhead for writing small chunks of data to disk.</para>
2381       </listitem>
2382     </itemizedlist>
2383   </section>
2384   <section xml:id="write_vs_read_performance">
2385     <title>
2386     <indexterm>
2387       <primary>tuning</primary>
2388       <secondary>write performance</secondary>
2389     </indexterm>Understanding Why Write Performance is Better Than Read
2390     Performance</title>
2391     <para>Typically, the performance of write operations on a Lustre cluster is
2392     better than read operations. When doing writes, all clients are sending
2393     write RPCs asynchronously. The RPCs are allocated, and written to disk in
2394     the order they arrive. In many cases, this allows the back-end storage to
2395     aggregate writes efficiently.</para>
2396     <para>In the case of read operations, the reads from clients may come in a
2397     different order and need a lot of seeking to get read from the disk. This
2398     noticeably hampers the read throughput.</para>
2399     <para>Currently, there is no readahead on the OSTs themselves, though the
2400     clients do readahead. If there are lots of clients doing reads it would not
2401     be possible to do any readahead in any case because of memory consumption
2402     (consider that even a single RPC (1 MB) readahead for 1000 clients would
2403     consume 1 GB of RAM).</para>
2404     <para>For file systems that use socklnd (TCP, Ethernet) as interconnect,
2405     there is also additional CPU overhead because the client cannot receive
2406     data without copying it from the network buffers. In the write case, the
2407     client CAN send data without the additional data copy. This means that the
2408     client is more likely to become CPU-bound during reads than writes.</para>
2409   </section>
2410 </chapter>
2411 <!--
2412   vim:expandtab:shiftwidth=2:tabstop=8:
2413   -->