1 .. _mlrsearch_algorithm:
6 Multiple Loss Rate search (MLRsearch) is a new search algorithm
7 implemented in FD.io CSIT project. MLRsearch discovers multiple packet
8 throughput rates in a single search, with each rate associated with a
9 distinct Packet Loss Ratio (PLR) criteria.
11 Two throughput measurements used in FD.io CSIT are Non-Drop Rate (NDR,
12 with zero packet loss, PLR=0) and Partial Drop Rate (PDR, with packet
13 loss rate not greater than the configured non-zero PLR). MLRsearch
14 discovers NDR and PDR in a single pass reducing required execution time
15 compared to separate binary searches for NDR and PDR. MLRsearch reduces
16 execution time even further by relying on shorter trial durations
17 of intermediate steps, with only the final measurements
18 conducted at the specified final trial duration.
19 This results in the shorter overall search
20 execution time when compared to a standard NDR/PDR binary search,
21 while guaranteeing the same or similar results.
23 If needed, MLRsearch can be easily adopted to discover more throughput rates
24 with different pre-defined PLRs.
26 .. Note:: All throughput rates are *always* bi-directional
27 aggregates of two equal (symmetric) uni-directional packet rates
28 received and reported by an external traffic generator.
33 The main properties of MLRsearch:
35 - MLRsearch is a duration aware multi-phase multi-rate search algorithm.
37 - Initial phase determines promising starting interval for the search.
38 - Intermediate phases progress towards defined final search criteria.
39 - Final phase executes measurements according to the final search
44 - Uses link rate as a starting transmit rate and discovers the Maximum
45 Receive Rate (MRR) used as an input to the first intermediate phase.
47 - *Intermediate phases*:
49 - Start with initial trial duration (in the first phase) and converge
50 geometrically towards the final trial duration (in the final phase).
51 - Track two values for NDR and two for PDR.
53 - The values are called (NDR or PDR) lower_bound and upper_bound.
54 - Each value comes from a specific trial measurement
55 (most recent for that transmit rate),
56 and as such the value is associated with that measurement's duration and loss.
57 - A bound can be invalid, for example if NDR lower_bound
58 has been measured with nonzero loss.
59 - Invalid bounds are not real boundaries for the searched value,
60 but are needed to track interval widths.
61 - Valid bounds are real boundaries for the searched value.
62 - Each non-initial phase ends with all bounds valid.
64 - Start with a large (lower_bound, upper_bound) interval width and
65 geometrically converge towards the width goal (measurement resolution)
66 of the phase. Each phase halves the previous width goal.
67 - Use internal and external searches:
69 - External search - measures at transmit rates outside the (lower_bound,
70 upper_bound) interval. Activated when a bound is invalid,
71 to search for a new valid bound by doubling the interval width.
72 It is a variant of `exponential search`_.
73 - Internal search - `binary search`_, measures at transmit rates within the
74 (lower_bound, upper_bound) valid interval, halving the interval width.
76 - *Final phase* is executed with the final test trial duration, and the final
77 width goal that determines resolution of the overall search.
78 Intermediate phases together with the final phase are called non-initial phases.
80 The main benefits of MLRsearch vs. binary search include:
82 - In general MLRsearch is likely to execute more search trials overall, but
83 less trials at a set final duration.
84 - In well behaving cases it greatly reduces (>50%) the overall duration
85 compared to a single PDR (or NDR) binary search duration,
86 while finding multiple drop rates.
87 - In all cases MLRsearch yields the same or similar results to binary search.
88 - Note: both binary search and MLRsearch are susceptible to reporting
89 non-repeatable results across multiple runs for very bad behaving
94 - Worst case MLRsearch can take longer than a binary search e.g. in case of
95 drastic changes in behaviour for trials at varying durations.
100 Following is a brief description of the current MLRsearch
101 implementation in FD.io CSIT.
106 #. *maximum_transmit_rate* - maximum packet transmit rate to be used by
107 external traffic generator, limited by either the actual Ethernet
108 link rate or traffic generator NIC model capabilities. Sample
109 defaults: 2 * 14.88 Mpps for 64B 10GE link rate,
110 2 * 18.75 Mpps for 64B 40GE NIC maximum rate.
111 #. *minimum_transmit_rate* - minimum packet transmit rate to be used for
112 measurements. MLRsearch fails if lower transmit rate needs to be
113 used to meet search criteria. Default: 2 * 10 kpps (could be higher).
114 #. *final_trial_duration* - required trial duration for final rate
115 measurements. Default: 30 sec.
116 #. *initial_trial_duration* - trial duration for initial MLRsearch phase.
118 #. *final_relative_width* - required measurement resolution expressed as
119 (lower_bound, upper_bound) interval width relative to upper_bound.
121 #. *packet_loss_ratio* - maximum acceptable PLR search criteria for
122 PDR measurements. Default: 0.5%.
123 #. *number_of_intermediate_phases* - number of phases between the initial
124 phase and the final phase. Impacts the overall MLRsearch duration.
125 Less phases are required for well behaving cases, more phases
126 may be needed to reduce the overall search duration for worse behaving cases.
127 Default (2). (Value chosen based on limited experimentation to date.
128 More experimentation needed to arrive to clearer guidelines.)
133 1. First trial measures at maximum rate and discovers MRR.
135 a. *in*: trial_duration = initial_trial_duration.
136 b. *in*: offered_transmit_rate = maximum_transmit_rate.
137 c. *do*: single trial.
138 d. *out*: measured loss ratio.
139 e. *out*: mrr = measured receive rate.
141 2. Second trial measures at MRR and discovers MRR2.
143 a. *in*: trial_duration = initial_trial_duration.
144 b. *in*: offered_transmit_rate = MRR.
145 c. *do*: single trial.
146 d. *out*: measured loss ratio.
147 e. *out*: mrr2 = measured receive rate.
149 3. Third trial measures at MRR2.
151 a. *in*: trial_duration = initial_trial_duration.
152 b. *in*: offered_transmit_rate = MRR2.
153 c. *do*: single trial.
154 d. *out*: measured loss ratio.
161 a. *in*: trial_duration for the current phase.
162 Set to initial_trial_duration for the first intermediate phase;
163 to final_trial_duration for the final phase;
164 or to the element of interpolating geometric sequence
165 for other intermediate phases.
166 For example with two intermediate phases, trial_duration
167 of the second intermediate phase is the geometric average
168 of initial_strial_duration and final_trial_duration.
169 b. *in*: relative_width_goal for the current phase.
170 Set to final_relative_width for the final phase;
171 doubled for each preceding phase.
172 For example with two intermediate phases,
173 the first intermediate phase uses quadruple of final_relative_width
174 and the second intermediate phase uses double of final_relative_width.
175 c. *in*: ndr_interval, pdr_interval from the previous main loop iteration
176 or the previous phase.
177 If the previous phase is the initial phase, both intervals have
178 lower_bound = MRR2, uper_bound = MRR.
179 Note that the initial phase is likely to create intervals with invalid bounds.
180 d. *do*: According to the procedure described in point 2,
181 either exit the phase (by jumping to 1.g.),
182 or prepare new transmit rate to measure with.
183 e. *do*: Perform the trial measurement at the new transmit rate
184 and trial_duration, compute its loss ratio.
185 f. *do*: Update the bounds of both intervals, based on the new measurement.
186 The actual update rules are numerous, as NDR external search
187 can affect PDR interval and vice versa, but the result
188 agrees with rules of both internal and external search.
189 For example, any new measurement below an invalid lower_bound
190 becomes the new lower_bound, while the old measurement
191 (previously acting as the invalid lower_bound)
192 becomes a new and valid upper_bound.
193 Go to next iteration (1.c.), taking the updated intervals as new input.
194 g. *out*: current ndr_interval and pdr_interval.
195 In the final phase this is also considered
196 to be the result of the whole search.
197 For other phases, the next phase loop is started
198 with the current results as an input.
200 2. New transmit rate (or exit) calculation (for 1.d.):
202 - If there is an invalid bound then prepare for external search:
204 - *If* the most recent measurement at NDR lower_bound transmit rate
205 had the loss higher than zero, then
206 the new transmit rate is NDR lower_bound
207 decreased by two NDR interval widths.
208 - Else, *if* the most recent measurement at PDR lower_bound
209 transmit rate had the loss higher than PLR, then
210 the new transmit rate is PDR lower_bound
211 decreased by two PDR interval widths.
212 - Else, *if* the most recent measurement at NDR upper_bound
213 transmit rate had no loss, then
214 the new transmit rate is NDR upper_bound
215 increased by two NDR interval widths.
216 - Else, *if* the most recent measurement at PDR upper_bound
217 transmit rate had the loss lower or equal to PLR, then
218 the new transmit rate is PDR upper_bound
219 increased by two PDR interval widths.
220 - If interval width is higher than the current phase goal:
222 - Else, *if* NDR interval does not meet the current phase width goal,
223 prepare for internal search. The new transmit rate is
224 (NDR lower bound + NDR upper bound) / 2.
225 - Else, *if* PDR interval does not meet the current phase width goal,
226 prepare for internal search. The new transmit rate is
227 (PDR lower bound + PDR upper bound) / 2.
228 - Else, *if* some bound has still only been measured at a lower duration,
229 prepare to re-measure at the current duration (and the same transmit rate).
230 The order of priorities is:
236 - *Else*, do not prepare any new rate, to exit the phase.
237 This ensures that at the end of each non-initial phase
238 all intervals are valid, narrow enough, and measured
239 at current phase trial duration.
241 Implementation Deviations
242 -------------------------
244 This document so far has been describing a simplified version of MLRsearch algorithm.
245 The full algorithm as implemented contains additional logic,
246 which makes some of the details (but not general ideas) above incorrect.
247 Here is a short description of the additional logic as a list of principles,
248 explaining their main differences from (or additions to) the simplified description,
249 but without detailing their mutual interaction.
251 1. *Logarithmic transmit rate.*
252 In order to better fit the relative width goal,
253 the interval doubling and halving is done differently.
254 For example, the middle of 2 and 8 is 4, not 5.
255 2. *Optimistic maximum rate.*
256 The increased rate is never higher than the maximum rate.
257 Upper bound at that rate is always considered valid.
258 3. *Pessimistic minimum rate.*
259 The decreased rate is never lower than the minimum rate.
260 If a lower bound at that rate is invalid,
261 a phase stops refining the interval further (until it gets re-measured).
262 4. *Conservative interval updates.*
263 Measurements above current upper bound never update a valid upper bound,
264 even if drop ratio is low.
265 Measurements below current lower bound always update any lower bound
266 if drop ratio is high.
267 5. *Ensure sufficient interval width.*
268 Narrow intervals make external search take more time to find a valid bound.
269 If the new transmit increased or decreased rate would result in width
270 less than the current goal, increase/decrease more.
271 This can happen if the measurement for the other interval
272 makes the current interval too narrow.
273 Similarly, take care the measurements in the initial phase
274 create wide enough interval.
275 6. *Timeout for bad cases.*
276 The worst case for MLRsearch is when each phase converges to intervals
277 way different than the results of the previous phase.
278 Rather than suffer total search time several times larger
279 than pure binary search, the implemented tests fail themselves
280 when the search takes too long (given by argument *timeout*).
282 .. _binary search: https://en.wikipedia.org/wiki/Binary_search
283 .. _exponential search: https://en.wikipedia.org/wiki/Exponential_search
284 .. _estimation of standard deviation: https://en.wikipedia.org/wiki/Unbiased_estimation_of_standard_deviation
285 .. _simplified error propagation formula: https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Simplification